#include <bits/stdc++.h>
using namespace std;
void file() {}
const int N = 2e5 + 5, M = 2e6 + 5, MOD = 1e9 + 7, OO = 1e9;
int n;
int a[100];
map<pair<int, pair<int, int>>, int> memo;
int solve(int indx, int money, int has) {
  if (indx == n) return 0;
  if (memo.count({indx, {money, has}})) return memo[{indx, {money, has}}];
  int ret = solve(indx + 1, money, has);
  for (int i = 1; i <= has; i++) {
    int take = i * a[indx];
    ret = max(ret, solve(indx + 1, money + take, has - i) + take);
  }
  for (int i = 1; i * a[indx] <= money; i++) {
    int take = i * a[indx];
    ret = max(ret, solve(indx + 1, money - take, has + i) - take);
  }
  return memo[{indx, {money, has}}] = ret;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  printf("%d\n", solve(0, 1000, 0) + 1000);
}
