#include <bits/stdc++.h>
using namespace std;
int n, a[66], l, l_, used[66], m, cnt;
bool done;
void dfs(int i) {
if (i == n) done = 1;
for (int j = 0; j != cnt && !done; ++j) {
if (a[i] + used[j] > l) continue;
used[j] += a[i];
dfs(-~i);
used[j] -= a[i];
if (a[i] + used[j] == l) return;
}
if (cnt == m || done) return;
used[cnt++] = a[i];
dfs(-~i);
used[--cnt] = 0;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 0; i != n; ++i)
cin >> a[i], l = a[i] > l ? a[i] : l, l_ += a[i];
sort(a, a + n, greater<>());
for (; l != l_; ++l) {
if (l_ % l) continue;
m = l_ / l, cnt = 0;
dfs(0);
if (done) break;
}
cout << l;
return 0;
}