PivotOJ

Always Know Where Your Towel Is

시간 제한: 4000ms메모리 제한: 1024MB출처: ICPC Rocky Mountain Regional 2024-2025BOJ 32662

문제

Arthur wants to go swimming. Another chance to use his favourite towel! He is concerned that if he leaves it out at the pool then someone might take it. So he keeps it in a locker.

Accessing the lockers is done in a peculiar way. One has to use an app on their phone to unlock the lockers. The app displays NN distinct positive integers whose sum is at most 2N22^N-2. The lockers are also numbered from 11 to 2N22^N-2. To open locker SS, one simply pushes a subset of buttons on the app (a "combination") whose sum is exactly SS. Pushing a button multiple times has the same effect as pushing it once, so there is no point to pushing a button more than once.

Arthur makes some observations. Oddly, it might be impossible to open some lockers. Also, since there are 2N12^N-1 nonempty subsets of buttons and each such subset has its values summing to an integer from 11 to 2N22^N-2, then there must be at least one locker that can be opened with more than one combination.

Arthur does not want to forget where he puts his towel when he goes swimming. He believes it will be easier to remember which locker he uses if it has more than one combination that can open it. Help Arthur find such a locker!

입력

The first line of input contains a single integer NN (3N423 \leq N \leq 42). Then next and final line contains NN positive integers a1,,aNa_1, \ldots, a_N. These integers are distinct and satisfy i=1Nai2N2\sum_{i=1}^N a_i \leq 2^N-2.

출력

Output a single integer SS (1S2N21 \leq S \leq 2^N-2) such that locker SS can be opened by more than one combination. If there are multiple possible solutions, any will suffice.

예제

예제 1

입력
5
2 5 8 4 7
출력
9

예제 2

입력
3
1 2 3
출력
3

예제 3

입력
7
19 24 11 23 9 21 18
출력
41
코드를 제출하려면 로그인하세요.