#include <bits/stdc++.h>
using namespace std;
const int N = 82;
const int M = 100010;
int n, a[N], dp[N][M];
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
  }
  for (int j = 0; j < M; ++j) {
    dp[n + 1][j] = j;
  }
  for (int i = n; i >= 1; --i) {
    for (int j = 0; j < M; ++j) {
      dp[i][j] = dp[i + 1][j];
      int buy = j / a[i], rem = j % a[i];
      if (buy) {
        for (int k = i + 1; k <= n; ++k)
          if (a[i] < a[k]) {
            dp[i][j] = max(dp[i][j], dp[k + 1][buy * a[k] + rem]);
          }
      }
    }
  }
  cout << dp[1][1000] << '\n';
  return 0;
}
