#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 0x3b9aca07;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;
ll dp[99][300];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  ll n, k;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < (int)n; ++i) cin >> a[i];
  queue<tuple<ll, ll, ll>> q;
  set<tuple<ll, ll, ll>> used;
  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.find({i + 1, 0, k + a[i] * j}) == used.end()) {
        q.emplace(i + 1, 0, k + a[i] * j);
        used.insert({i + 1, 0, k + a[i] * j});
      }
    }
    if (used.find({i + 1, j, k}) == used.end()) {
      q.emplace(i + 1, j, k);
      used.insert({i + 1, j, k});
    }
    ll num = k / a[i];
    if (used.find({i + 1, j + num, k - num * a[i]}) == used.end()) {
      q.emplace(i + 1, j + num, k - num * a[i]);
      used.insert({i + 1, j + num, k - num * a[i]});
    }
  }
  cout << ans << endl;
  return 0;
}
