Sum Set
Time limit1sMemory limit128 MB
Given a set of distinct integers, find the largest element d that equals the sum of three other distinct elements.
- Level
Medium6 of 10
- Topics
- Hash map, Brute force, Sorting
- Solved
- No attempts yet
Statement
You are given a set of integers. Among four distinct elements , , , of , find the largest such that .
Input
The input consists of several test cases.
The first line of each test case contains the size () of the set . Each of the next lines contains one element of , an integer between and . The elements of a set are all distinct.
The last line of the input contains , marking the end of input.
Output
For each test case, print the largest that satisfies the condition on its own line. If no such exists, print no solution.