#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> arr;
int visited[1000][100] = {0};
int memo[1000][100];
int dp(int curr, int stock, int ind) {
  if (ind == n) return curr;
  if (visited[stock][ind]) return memo[stock][ind];
  visited[stock][ind] = 1;
  int mx = curr;
  int price = arr[ind];
  for (int i = 0; i <= stock; i++) {
    int money = curr + i * price;
    int num = money / price;
    for (int j = 0; j <= num; j++) {
      int temp = money - price * j;
      mx = max(mx, dp(temp, stock - i + j, ind + 1));
    }
  }
  memo[stock][ind] = mx;
  return mx;
}
int main() {
  cin >> n;
  arr.resize(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  int ans = dp(1000, 0, 0);
  cout << ans;
  return 0;
}
