#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
int n, a[100], mem[100];
bool cmp(int x, int y) {
return x > y;
}
bool bo[100], ans;
bool dfs(int le, int cnt, int lim, int now) {
if (ans)return 1;
if (!le) {
if (cnt == n) {
ans = 1;
return 1;
}
else if (!dfs(lim, cnt, lim, 1))return 0;
return 1;
}
for (int i = now; i <= n; i++) {
if (le >= a[i] && (!bo[i])) {
bo[i] = 1;
if (!dfs(le - a[i], cnt + 1, lim, i + 1)) {
if (le == lim) {
bo[i] = 0;
return 0;
}
bo[i] = 0;
i = mem[a[i]];
}
}
}
return 0;
}
int main() {
cin >> n;
int sum = 0;
for (int i = 1; i <= n; i++) {
cin >> a[i];
sum += a[i];
}
sort(a + 1, a + n + 1, cmp);
for (int i = 1; i <= n; i++) {
if (a[i] != a[i + 1]) {
mem[a[i]] = i;
}
}
for (int i = a[1]; i <= sum; i++) {
dfs(i, 0, i, 1);
if (ans) {
cout << i << endl;
return 0;
}
}
}