시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 137 23 17 16.346%

문제

정수 집합 S가 주어졌을 때, a + b + c = d를 만족하는 가장 큰 d를 구하는 프로그램을 작성하시오. 이때, a, b, c, d는 S의 원소이며, 서로 다른 수이다.

입력

입력은 여러 개의 테스트 케이스로 이루어져 있다. 각 테스트 케이스의 첫째 줄에는 집합 S의 크기 n(1 ≤ n ≤ 1000)이 주어진다. 다음 줄부터 n개의 줄에는 집합 S의 원소(-536870912와 ~ +536870911)가 하나씩 주어진다. 집합의 원소는 중복되지 않는다. 입력의 마지막 줄에는 0이 주어진다.

출력

각 테스트 케이스에 대해서, 가장 큰 d를 출력한다. d가 없는 경우에는 "no solution"을 출력한다.

예제 입력 1

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

예제 출력 1

12
no solution
W3sicHJvYmxlbV9pZCI6IjQzNzMiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWMyMThcdWM5ZDFcdWQ1NjkiLCJkZXNjcmlwdGlvbiI6IjxwPlxyXG5cdFx1YzgxNVx1YzIxOCBcdWM5ZDFcdWQ1NjkgU1x1YWMwMCBcdWM4ZmNcdWM1YjRcdWM4NGNcdWM3NDQgXHViNTRjLCBhICsgYiArIGMgPSBkXHViOTdjIFx1YjljY1x1Yzg3MVx1ZDU1OFx1YjI5NCBcdWFjMDBcdWM3YTUgXHVkMDcwIGRcdWI5N2MgXHVhZDZjXHVkNTU4XHViMjk0IFx1ZDUwNFx1Yjg1Y1x1YWRmOFx1YjdhOFx1Yzc0NCBcdWM3OTFcdWMxMzFcdWQ1NThcdWMyZGNcdWM2MjQuIFx1Yzc3NFx1YjU0YywgYSwgYiwgYywgZFx1YjI5NCBTXHVjNzU4IFx1YzZkMFx1YzE4Y1x1Yzc3NFx1YmE3MCwgXHVjMTFjXHViODVjIFx1YjJlNFx1Yjk3OCBcdWMyMThcdWM3NzRcdWIyZTQuPFwvcD5cclxuIiwiaW5wd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