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