#include <bits/stdc++.h>
using namespace std;
const long long mxn = 110;
long long a[mxn];
long long n;
long long dp[85][100][5000];
long long solve(long long i, long long have, long long val) {
  if (i > n) return 0;
  if (dp[i][have][val] != -1) return dp[i][have][val];
  long long ans = val + (have * a[i]);
  ans = max({ans, solve(i + 1, 0, val + (have * a[i])),
             solve(i + 1, have + (val / a[i]), val % a[i])});
  return dp[i][have][val] = ans;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  cout << solve(1, 0, 1000) << "\n";
  return 0;
}
