#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
int n, b[85], ans, sz;
vector<int> a;
void fnc(int tk, int stock, int pos) {
  ans = max(ans, tk);
  if (pos == sz || tk < 0 || stock < 0) return;
  if (tk != 0 && tk >= a[pos])
    fnc(tk - ((tk / a[pos]) * a[pos]), (tk / a[pos]), pos + 1);
  if (stock != 0) fnc(tk + (stock * a[pos]), 0, pos + 1);
  if (tk == 0 || stock == 0) fnc(tk, stock, pos + 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> b[i];
  a.push_back(b[0]);
  for (int i = 1; i < n; i++) {
    if (b[i] != b[i - 1]) a.push_back(b[i]);
  }
  sz = a.size();
  fnc(1000, 0, 0);
  cout << ans << endl;
  return 0;
}
