Time limit
1s
Memory limit
128 MB
Given a set U of N distinct positive integers, choose three numbers from U. The same element may be chosen more than once. If the sum of the three chosen numbers is also an element of U, that sum is a valid candidate. Find the largest valid candidate.
The first line contains the positive integer N (5 <= N <= 1,000). Each of the next N lines contains one element of U. All given elements are distinct positive integers not greater than 200,000,000. The input is guaranteed to have at least one valid answer.
Print the largest element d of U that can be written as x + y + z, where x, y, and z are elements of U. The same element may be used for more than one of x, y, and z.