#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int N = 2e5 + 5;
int n, a[85];
map<pair<int, pair<long long, long long>>, long long> memo;
long long solve(int i, long long j, long long k) {
  if (i == n) return k;
  if (memo.count({i, {j, k}})) return memo[{i, {j, k}}];
  long long ans = solve(i + 1, j + k / a[i], k % a[i]);
  ans = max(ans, solve(i + 1, 0, k + j * a[i]));
  return memo[{i, {j, k}}] = ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  cout << solve(0, 0, 1000);
  return 0;
}
