#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <unordered_map>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for(int i = (int)n - 1; j <= i; --i)

constexpr ll MOD = 0x3b9aca07;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

ll dp[99][300];
unordered_map<tuple<ll, ll, ll>, bool> used;

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);

	ll n, k; cin >> n;
	vector<ll> a(n); rep(i, 0, n) cin >> a[i];
	// 80000
	queue < tuple<ll, ll, ll>> q;
	ll ans = 0;
	q.emplace(0, 0, 1000);
	while (q.size()) {
		ll i, j, k;
		tie(i, j, k) = q.front();
		q.pop();
		if (i == n) {
			ans = max(ans, k);
			continue;
		}
		if (j > 0) {
			if (!used[{ i + 1, 0, k + a[i] * j }]) {
				q.emplace(i + 1, 0, k + a[i] * j);
				used[{i + 1, 0, k + a[i] * j }] = true;
			}
		}
		if (!used[{ i + 1, j, k }]) {
			q.emplace(i + 1, j, k);
			used[{ i + 1, j, k }] = true;
		}

		ll num = k / a[i];
		if (!used[{ i + 1, j + num, k - num * a[i] }]) {
			q.emplace(i + 1, j + num, k - num * a[i]);
			used[{i + 1, j + num, k - num * a[i]}] = true;
		}
	}
	cout << ans << endl;

	return 0;
}
