Fully working sum_pair_loop.