implementation of SumN.