#include <bits/stdc++.h>
using namespace std;
const int NN = 90, M = 1e4, S = 100;
int dp[NN][M][S];
int main() {
  int N;
  cin >> N;
  vector<int> price(N + 1);
  for (int i = 1; i <= N; i++) cin >> price[i];
  for (int i = N; i > 0; i--) {
    for (int m = 0; m < M; m++) {
      for (int s = 0; s < S; s++) {
        dp[i][m][s] = 0;
        if (i == N)
          dp[i][m][s] = m + price[i] * s;
        else {
          dp[i][m][s] = max(dp[i][m][s], dp[i + 1][m][s]);
          dp[i][m][s] = max(dp[i][m][s], dp[i + 1][m + s * price[i]][0]);
          dp[i][m][s] =
              max(dp[i][m][s], dp[i + 1][m % price[i]][s + m / price[i]]);
        }
      }
    }
  }
  cout << dp[1][1000][0] << "\n";
  return 0;
}
