#include <bits/stdc++.h>
using namespace std;
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
void file() {}
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
}
const int N = 1e3 + 1;
int mem[80][N * 10][N / 10];
int n;
vector<int> v1;
int solve(int idx, int yen, int stc) {
  if (idx == n) return yen;
  int& ret = mem[idx][yen][stc];
  if (ret != -1) return ret;
  ret = solve(idx + 1, yen, stc);
  ret = max(ret, solve(idx, yen % v1[idx], stc + yen / v1[idx]));
  ret = max(ret, solve(idx + 1, yen + stc * v1[idx], 0));
  return ret;
}
int main() {
  file();
  fast();
  memset(mem, -1, sizeof mem);
  cin >> n;
  v1 = vector<int>(n);
  for (auto& it : v1) cin >> it;
  cout << solve(0, 1000, 0);
  return 0;
}
