#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
long long int ans = 0;
long long int n;
vector<long long int> A;
map<pair<long long int, pair<long long int, long long int>>, bool> vis;
void func(long long int now, long long int money, long long int kabu) {
  if (vis[{now, {money, kabu}}]) return;
  if (now == n) {
    chmax(ans, money);
    return;
  }
  vis[{now, {money, kabu}}] = true;
  func(now + 1, money, kabu);
  func(now + 1, money + kabu * A[now], 0);
  long long int nowMoney = money;
  func(now + 1, money % A[now], kabu + nowMoney / A[now]);
}
void func() {
  long long int now = 1000;
  long long int kabu = 0;
  func(0, 1000, 0);
  cout << ans << endl;
}
int main() {
  scanf("%lld", &n);
  A.resize(n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &A[i]);
  }
  func();
  return 0;
}
