#include <bits/stdc++.h>
using namespace std;
const int N = 4005;
int n, m, len;
long long dp[81][101][2005];
int a[N];
long long fun(int idx, long long stock, long long tk) {
  if (idx > n) {
    return tk;
  }
  long long &ret = dp[idx][stock][tk];
  if (-1 != ret) {
    return ret;
  }
  int r1, r2, r3;
  r1 = r2 = r3 = 0;
  r1 = fun(idx + 1, stock + tk / a[idx], tk % a[idx]);
  r2 = fun(idx + 1, 0, tk + 1LL * stock * a[idx]);
  r3 = fun(idx + 1, stock, tk);
  return ret = max({r1, r2, r3});
}
void HalfDead() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  memset(dp, -1, sizeof dp);
  cout << fun(1, 0, 1000) << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  int tc = 1;
  while (tc--) {
    HalfDead();
  }
  return 0;
}
