O(1) since the array is sorted we have to find the sum of first two elements only if their sum is less than 1000 than output will be yes if not than since the elements are sorted if the sum of first two elements is not less than 1000 than the sum of no two elements would be less than 1000 and output would be no.