//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragme GCC target("avx2");
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
//#define int long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fsdalfjlas x1
#define djfdslfka y1


using namespace std;
using namespace __gnu_pbds;

/*
	st.insert(k);
	st.find_by_order(k); iterator on k-th from 0
	st.order_of_key(k); strictly less than k
*/

typedef
tree<
  ll,
  null_type,
  less_equal<ll>,
  rb_tree_tag,
  tree_order_statistics_node_update>
ordered_set;


const ll mod = 1e9 + 7;


inline int modulo(int x) {x %= mod; return (x + mod) % mod; }
inline int mult(int x, int y) { ll x1 = modulo(x), y1 = modulo(y); return (x1 * y1) % (mod * 1ll); }
//inline void add(int &x, int y) { x = modulo(x + y); }
inline void Max(int &x, int y) { x = max(x, y); }
inline void Min(int &x, int y) { x = min(x, y); }


const int blocksz = 500;
const int inf = 2e9 + 1;
const ll INF = 1e16 + 2;
const int N = 100;
const int M = 2e5 + 10;
const int LIM = 1000000000;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int n, a[100], last[40002][402];
queue <pii> q;


main() {
//	ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
//	cin.tie(NULL); cout.tie(NULL);
//  	freopen("input.txt", "r", stdin);
//	freopen("pizza.in", "r", stdin);
//	freopen("pizza.out", "w", stdout);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	q.push({1000, 0});
	for (int i = 1; i <= n; i++) {
		int sz = q.size();
		pii tmp;
		for (int j = 1; j <= sz; j++) {
			int cash, stocks;
			tmp = q.front();
			q.pop();
			cash = tmp.fi; stocks = tmp.se;
			int lim = cash / a[i];
			for (int k = 1; k <= lim; k++)
				if (last[cash - k * a[i]][stocks + k] != i) {
					last[cash - k * a[i]][stocks + k] = i;
					q.push({cash - k * a[i], stocks + k});
				}
			for (int k = 0; k <= stocks; k++) {
				if (last[cash + k * a[i]][stocks - k] != i) {
					last[cash + k * a[i]][stocks - k] = i;
					q.push({cash + k * a[i], stocks - k});
				}
			}
		}
	}
	for (int i = 40000; i >= 1; i--) {
		bool flag = false;
		for (int j = 0; j <= 400; j++)
			if (last[i][j] == n) {
				flag = true;
				break;
			}
		if (flag)
			return cout << i, 0;
	}
}