#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  vector<vector<ll>> dp(n + 1, vector<ll>(50000, -1LL));
  dp[0][1000] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < 50000; ++j) {
      if (dp[i - 1][j] >= 0) {
        dp[i][j] = max(dp[i][j], dp[i - 1][j]);
        dp[i][j + dp[i - 1][j] * a[i]] =
            max(dp[i][j + dp[i - 1][j] * a[i]], 0LL);
        dp[i][j % a[i]] = max(dp[i][j % a[i]], dp[i - 1][j] + j / a[i]);
      }
    }
  }
  ll ans = 0;
  for (ll i = 0; i < 50000; ++i) {
    if (dp[n][i] >= 0) ans = max(ans, i);
  }
  cout << ans << endl;
  return 0;
}
