Implementing array pair sum problem