Iterative procedure for sum