#Lutece1142. Meet-in-the-middle

Meet-in-the-middle

Migrated from Lutece 1142 Meet-in-the-middle

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

Given S, a set of integers, find the largest dd such that a+b+c=da + b + c = d where a,b,c,a, b, c, and dd are distinct elements of S.

Input

Several S, each consisting of a line containing an integer 1n10001 ≤ n ≤ 1000 indicating the number of elements in S, followed by the elements of S, in a line. Each element of S is a distinct integer between 536870912-536870912 and +536870911+536870911 inclusive. The last line of input contains 00.

Output

For each S, a single line containing dd, or a single line containing no solution.

Samples

5
2 3 5 7 12
5
2 16 64 256 1024
0
12
no solution

Resources

peterpan