calculation of sum