#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);
using namespace std;
void scans(string& str) {
  char c;
  str = "";
  scanf("%c", &c);
  if (c == '\n') scanf("%c", &c);
  while (c != '\n' && c != -1 && c != ' ') {
    str += c;
    scanf("%c", &c);
  }
}
void scanc(char& str) {
  char c;
  scanf("%c", &c);
  if (c == -1) return;
  while (c == '\n') {
    scanf("%c", &c);
  }
  str = c;
}
double acot(double x) { return PI / 2 - atan(x); }
ll LSB(ll n) { return (n & (-n)); }
void dfs(const int& n, const vector<int>& a, const int& money, const int& kabu,
         const int& day, int& ans) {
  if (day == n) {
    ans = max(ans, money);
  } else {
    for (int i = 0; money - a[day] * i >= 0; ++i)
      dfs(n, a, money - a[day] * i, kabu + i, day + 1, ans);
    for (int i = 1; kabu - i >= 0; ++i)
      dfs(n, a, money + a[day] * i, kabu - i, day + 1, ans);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) scanf("%d", &a[i]);
  int ans = 0;
  dfs(n, a, 1000, 0, 0, ans);
  printf("%d\n", ans);
  return 0;
}
