#include <bits/stdc++.h>
using namespace std;
using ll = long long;
inline int popcount(const int x) { return __builtin_popcount(x); }
template <class T>
void chmin(T &a, const T &b) noexcept {
  if (b < a) a = b;
}
template <class T>
void chmax(T &a, const T &b) noexcept {
  if (a < b) a = b;
}
template <class T>
void drop(const T &x) {
  std::cout << x << endl;
  exit(0);
}
void debug_out() { std::cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &...args) {
  std::cout << x << " ";
  debug_out(args...);
}
struct InitIO {
  InitIO() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
  }
} init_io;
int n;
int dfs(int j, int v, int k, const vector<int> &a) {
  if (j == n) return v;
  int res1 = 0;
  for (int i = 0; i < (v / a[j] + 1); ++i) {
    if (v - a[j] * i < 0) break;
    chmax(res1, dfs(j + 1, v - a[j] * i, k + i, a));
  }
  int res2 = 0;
  for (int i = 0; i < (k + 1); ++i) {
    chmax(res2, dfs(j + 1, v + a[j] * i, k - i, a));
  }
  return max(res1, res2);
}
int main() {
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  cout << dfs(0, 1000, 0, a) << endl;
  return 0;
}
