#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
 int N;
 cin >> N;
 vector<int> T(N);
 int sum = 0;
 for (int i = 0; i < N; i++) {
   cin >> T.at(i);
   sum = sum + T.at(i);
 }
 sum /= 2;
 vector<bool> ans(sum + 1, false);
 ans.at(0) = true;
 int pmax = 0;
 for (int i = 0; i < N; i++) {
   for (int j = min(pmax, sum); j >= 0; j--) {
     if (T.at(i) + j <= sum && ans.at(j) == true) {
       ans.at(j + T.at(i)) = true;
     }
   }
   pmax += T.at(i);
  }
  for (int i = sum; i >= 0; i--) {
    if (ans.at(i) == true) {
      cout << pmax - i << endl;
      return 0;
    }
  }
}
#include <bits/stdc++.h>
using namespace std;

template<typename T> void read(T &x) {
	x = 0; int f = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') f = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + (ch - 48);
		ch = getchar();
	}
	x *= f;
}

typedef long long LL;

int n;
LL ans = 1;

LL gcd(LL a, LL b) {
	return (b == 0) ? a : gcd(b, a % b);
}

LL lcm(LL a, LL b) {
	return a * b / gcd(a, b);
}

int main() {
	read(n);
	for (LL i = 2; i <= n; i++) {
		ans = lcm(ans, i);
	}
	cout << ans + 1 << endl;
	return 0;
}