Sumsets

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

The input starts with an integer $1 \le N \le 4\, 000$, the number of elements in $S$. It is followed by $N$ lines containing the elements of $s$, one per line. Each element of $S$ is a distinct integer between $-536\, 870\, 912$ and $+536\, 870\, 911$, inclusive.

Output a single line containing the maximum $d$ as described in the statement. If
no such $d$ exists, output
a single line containing `no
solution`.

Sample Input 1 | Sample Output 1 |
---|---|

5 2 3 5 7 12 |
12 |

Sample Input 2 | Sample Output 2 |
---|---|

5 2 16 64 256 1024 |
no solution |