#include <bits/stdc++.h>
using namespace std;
constexpr long long INF = 2e18;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAXN = 2e5 + 3;
map<tuple<long long, long long, long long>, long long> dp;
vector<long long> arr;
long long f(long long idx, long long s, long long d) {
  if (idx == arr.size()) return d;
  if (dp.count(tuple<long long, long long, long long>(idx, s, d)))
    return dp[tuple<long long, long long, long long>(idx, s, d)];
  long long &ret = dp[tuple<long long, long long, long long>(idx, s, d)];
  ret = f(idx + 1, s + d / arr[idx], d % arr[idx]);
  ret = max(ret, f(idx + 1, 0, d + s * arr[idx]));
  ret = max(ret, f(idx + 1, s, d));
  return ret;
}
void solve() {
  long long n;
  cin >> n;
  arr.resize(n);
  for (long long &x : arr) {
    cin >> x;
  }
  cout << f(0, 0, 1000) << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) solve();
}
