Adding two-sum algorithm.