Characterization of arithmetic functions that preserve the sum