#include <bits/stdc++.h>
using namespace std;
const char en = '\n';
constexpr long long INF = 1000000000;
constexpr long long MOD = 1000000007;
void add_edge(vector<vector<long long>>& g, long long from, long long to,
              bool isDirected) {
  g[from].push_back(to);
  if (!isDirected) g[to].push_back(from);
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  } else
    return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  } else
    return false;
}
int n;
long long dfs(int money, int kabu, int ix, bool buy, vector<long long>& a) {
  long long ret = money + kabu * a[ix];
  if (a[ix] < money)
    for (int i = ix + 1; i < n; ++i)
      chmax(ret, dfs(money % a[ix], kabu + money / a[ix], i, !buy, a));
  if (kabu > 0)
    for (int i = ix + 1; i < n; ++i)
      chmax(ret, dfs(money + kabu * a[ix], 0, i, !buy, a));
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  cout << max(dfs(1000, 0, 0, false, a), dfs(1000, 0, 0, true, a)) << endl;
}
