Sort the array in ascending order. Take the 0th element and the rightmost one. Add them up, if the sum is greater than the desired number, then the right element decreases by one, if less, then the left one increases by one, and so on until you find the desired one or they meet.