2 queue summation algorithm