#include <bits/stdc++.h>
using namespace std;
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};
int XX[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int YY[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
long long int price[85];
long long int n;
long long int dp[30][81][80001];
long long int maximumsum(long long int stock, long long int indx,
                         long long int sum) {
  if (indx >= n) return sum;
  if (dp[stock][indx][sum] != -1) return dp[stock][indx][sum];
  long long int ans = sum;
  for (int i = 0; i <= sum / price[indx]; i++)
    ans = max(ans, maximumsum(stock + i, indx + 1, sum - (i * price[indx])));
  for (int i = 0; i <= stock; i++)
    ans = max(ans, maximumsum(stock - i, indx + 1, sum + (i * price[indx])));
  return dp[stock][indx][sum] = ans;
}
void solve() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> price[i];
  memset(dp, -1, sizeof(dp));
  cout << maximumsum(0, 0, 1000);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  { solve(); }
  return 0;
}
