#include <bits/stdc++.h>
using namespace std;
void read(long long int n = 10) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << setprecision(n) << fixed;
}
long long int M = 1e9 + 7;
long long int M1 = 998244353;
long long int n;
vector<long long int> arr;
vector<vector<vector<long long int>>> dp;
long long int solve(long long int ind, long long int money,
                    long long int stock) {
  if (ind == n - 1) return money + stock * arr[ind];
  if (dp[ind][money][stock] != -1) return dp[ind][money][stock];
  long long int rs =
      solve(ind + 1, money % arr[ind], stock + (money / arr[ind]));
  rs = max(rs, solve(ind + 1, money + stock * arr[ind], 0));
  return dp[ind][money][stock] = rs;
}
int32_t main() {
  read();
  cin >> n;
  arr.resize(n);
  dp.resize(
      n, vector<vector<long long int>>(10000, vector<long long int>(15, -1)));
  for (long long int i = 0; i < n; i++) cin >> arr[i];
  cout << solve(0, 1000, 0);
}
