시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 134 20 16 15.686%

문제

정수 집합 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

힌트

W3sicHJvYmxlbV9pZCI6IjQzNzMiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWMyMThcdWM5ZDFcdWQ1NjkiLCJkZXNjcmlwdGlvbiI6IjxwPlxyXG5cdFx1YzgxNVx1YzIxOCBcdWM5ZDFcdWQ1NjkgU1x1YWMwMCBcdWM4ZmNcdWM1YjRcdWM4NGNcdWM3NDQgXHViNTRjLCBhICsgYiArIGMgPSBkXHViOTdjIFx1YjljY1x1Yzg3MVx1ZDU1OFx1YjI5NCBcdWFjMDBcdWM3YTUgXHVkMDcwIGRcdWI5N2MgXHVhZDZjXHVkNTU4XHViMjk0IFx1ZDUwNFx1Yjg1Y1x1YWRmOFx1YjdhOFx1Yzc0NCBcdWM3OTFcdWMxMzFcdWQ1NThcdWMyZGNcdWM2MjQuIFx1Yzc3NCBcdWI1NGMsIGEsIGIsIGMsIGRcdWIyOTQgU1x1Yzc1OCBcdWM2ZDBcdWMxOGNcdWM3NzRcdWJhNzAsIFx1YzExY1x1Yjg1YyBcdWIyZTRcdWI5NzggXHVjMjE4XHVjNzc0XHViMmU0LjxcL3A+XHJcb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