#include <bits/stdc++.h>
using namespace std;
int n;
int arr[89];
int dp[89][10009][89];
int solve(int idx, int money, int stocks) {
  if (idx == n) return money;
  if (dp[idx][money][stocks] != -1) return dp[idx][money][stocks];
  int ans = solve(idx + 1, money, stocks);
  for (int i = 1; i * arr[idx] <= money; i++) {
    ans = max(ans, solve(idx + 1, money - (i * arr[idx]), stocks + i));
  }
  for (int i = 1; i <= stocks; i++) {
    ans = max(ans, solve(idx + 1, money + (i * arr[idx]), stocks - i));
  }
  return dp[idx][money][stocks] = ans;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  memset(dp, -1, sizeof dp);
  cout << solve(0, 1000, 0) << endl;
  return 0;
}
