#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int a[N];
int n, m;
int mem[20010][81][81];
int dp(int x, int mon, int nm) {
  if (x == n) {
    return mon;
  }
  if (mem[mon][x][nm] != -1) {
    return mem[mon][x][nm];
  }
  int res = dp(x + 1, mon, nm);
  if (nm > 0) {
    res = max(res, dp(x + 1, mon + nm * a[x], 0));
  }
  if (mon >= a[x]) {
    res = max(res, dp(x + 1, mon % a[x], nm + mon / a[x]));
  }
  mem[mon][x][nm] = res;
  return res;
}
int main() {
  int t;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  memset(mem, -1, sizeof mem);
  int ans = dp(0, 1000, 0);
  cout << ans << endl;
}
