#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int dp[81][1000];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  using T = tuple<int, int, int>;
  queue<T> qu;
  qu.emplace(0, 0, 1000);
  int res = 0;
  while (!qu.empty()) {
    int i, j, k;
    tie(i, j, k) = qu.front();
    qu.pop();
    if (i == N) {
      res = max(res, k);
    } else {
      qu.emplace(i + 1, 0, k + A[i] * j);
      qu.emplace(i + 1, j + k / A[i], k - k / A[i] * A[i]);
    }
  }
  cout << res << endl;
  return 0;
}
