#include <bits/stdc++.h>
using namespace std;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
struct UnionFind {
  vector<int> par, rank;
  UnionFind(int n) : par(n), rank(n) {
    for (int i = 0; i < n; ++i) par[i] = i;
  }
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    int rx = root(x), ry = root(y);
    if (rx == ry) return;
    if (rank[ry] > rank[rx])
      par[rx] = ry;
    else
      par[ry] = rx;
    if (rank[rx] == rank[ry]) rank[rx]++;
  }
  bool same(int x, int y) { return root(x) == root(y); }
};
vector<long long> fac(1e6), inv(1e6), finv(1e6);
void initcom() {
  fac[0] = fac[1] = 1;
  inv[1] = 1;
  finv[0] = finv[1] = 1;
  for (int i = 2; i < 1e6; ++i) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long com(int n, int k) {
  if (n < 0 || k < 0) return 0;
  if (n < k) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int compress(vector<int> &x, int w) {
  vector<int> sx;
  for (int i = 0; i < (int)x.size(); ++i) {
    for (int d = -2; d <= 2; ++d) {
      int t = x[i] + d;
      if (t >= 0 && t < w) sx.push_back(t);
    }
  }
  sort(sx.begin(), sx.end());
  sx.erase(unique(sx.begin(), sx.end()), sx.end());
  for (int i = 0; i < (int)x.size(); ++i) {
    x[i] = lower_bound(x.begin(), x.end(), x[i]) - x.begin();
  }
  return (int)sx.size();
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  int dp[n + 1][16001];
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= 16000; ++j) {
      dp[i][j] = -1;
    }
  }
  dp[0][1000] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= 16000; ++j) {
      if (dp[i][j] == 0) {
        dp[i + 1][j] = max(dp[i + 1][j], 0);
        dp[i + 1][j % a[i]] = max(dp[i + 1][j % a[i]], j / a[i]);
      } else if (dp[i][j] >= 1) {
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        dp[i + 1][j + dp[i][j] * a[i]] = max(dp[i + 1][j + dp[i][j] * a[i]], 0);
      }
    }
  }
  int ans = 1000;
  for (int j = 1000; j <= 16000; ++j) {
    if (dp[n][j] >= 0) ans = max(ans, j);
  }
  cout << ans << endl;
  return 0;
}
