#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFLL = 0x3f3f3f3f3f3f3f3f;
long long TESTCASE_NUM = 1;
template <typename T>
inline void _read(T &x) {
  cin >> x;
}
inline void _read(int &x) { scanf("%d", &x); }
inline void _read(long long &x) { scanf("%lld", &x); }
inline void _read(float &x) { scanf("%f", &x); }
inline void _read(double &x) { scanf("%lf", &x); }
inline void _read(char &x) { x = getchar(); }
inline void _read(char *x) { scanf("%s", x); }
inline void read() {}
template <typename T, typename... U>
inline void read(T &head, U &...tail) {
  _read(head);
  read(tail...);
}
template <typename T>
inline void _write(const T &x) {
  cout << x;
}
inline void _write(const int &x) { printf("%d", x); }
inline void _write(const long long &x) { printf("%lld", x); }
inline void _write(const float &x) { printf("%.6f", x); }
inline void _write(const double &x) { printf("%.8lf", x); }
inline void _write(const char &x) { putchar(x); }
inline void _write(const char *x) { printf("%s", x); }
inline void write() {}
template <typename T, typename... U>
inline void write(const T &head, const U &...tail) {
  _write(head);
  write(tail...);
}
inline void debug() {}
template <typename T, typename... U>
inline void debug(const T &head, const U &...tail) {}
void solve();
void init();
template <typename T1, typename T2>
inline T1 max(T1 a, T2 b) {
  return a < b ? b : a;
}
template <typename T1, typename T2>
inline T1 min(T1 a, T2 b) {
  return a < b ? a : b;
}
template <typename T>
inline bool isprime(T p) {
  if (p == 2 || p == 3) return 1;
  if (p < 2 || (p % 6 != 1 && p % 6 != 5)) return 0;
  for (T i = 5; i * i <= p; i = i + 6)
    if (p % i == 0 || p % (i + 2) == 0) return 0;
  return 1;
}
void DISPLAY_DEBUG_INFO() {}
signed main() {
  init();
  while (TESTCASE_NUM--) {
    solve();
  }
  DISPLAY_DEBUG_INFO();
  return 0;
}
const long long MAXN = 2e5 + 10;
const int MOD = 1e9 + 7;
void init() {}
long long a[100];
long long n;
int pre[90][18000][200];
int dfs(int day, int money, int goods) {
  int save = pre[day][money][goods];
  if (save != 0) {
    if (save == -1)
      return 0;
    else
      return save;
  }
  if (day == n + 1) {
    return money;
  }
  int maxn = -INF;
  int canbuy = money / a[day];
  for (int i = 0; i <= canbuy; i++) {
    maxn = max(maxn, dfs(day + 1, money - i * a[day], goods + i));
  }
  for (int i = 1; i <= goods; i++) {
    maxn = max(maxn, dfs(day + 1, money + i * a[day], goods - i));
  }
  if (maxn == 0) {
    pre[day][money][goods] = -1;
  } else {
    pre[day][money][goods] = maxn;
  }
  return maxn;
}
void solve() {
  read(n);
  for (int i = 1; i <= n; i++) {
    read(a[i]);
  }
  write(dfs(1, 1000, 0), '\n');
}
