#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
const int N = 90, A = 18000;
const ll inf = 1e18;
ll dp[N][N][A];
int a[N], n;
bool vis[N][N][A];
ll f(int i, int s, int m) {
  assert(m <= A);
  if (i == n) return m;
  if (!vis[i][s][m]) {
    dp[i][s][m] = max({f(i + 1, s, m), f(i + 1, 0, m + a[i] * s),
                       f(i + 1, s + m / a[i], m % a[i])});
    vis[i][s][m] = true;
  }
  return dp[i][s][m];
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  for (auto i = (0); i < (n); ++i) cin >> a[i];
  cout << f(0, 0, 1000);
}
