#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ld = long double;
constexpr long long mod = (ll)1e9 + 7;
constexpr long long Mod = 998244353;
constexpr ld EPS = 1e-10;
constexpr ll inf = (ll)3 * 1e18;
constexpr long long Inf = (ll)15 * 1e8;
constexpr long long dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, -1, 1};
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
ll read() {
  ll u, k = scanf("%lld", &u);
  return u;
}
string reads() {
  string s;
  cin >> s;
  return s;
}
pair<long long, long long> readh(short g = 0) {
  pair<long long, long long> u;
  long long k = scanf("%lld %lld", &u.first, &u.second);
  if (g == 1) u.first--, u.second--;
  if (g == 2) u.first--;
  return u;
}
bool ina(pair<long long, long long> t, long long h, long long w) {
  return 0 <= t.first && t.first < h && 0 <= t.second && t.second < w;
}
bool ina(long long t, long long l, long long r) { return l <= t && t < r; }
ll gcd(ll i, ll j) { return j ? gcd(j, i % j) : i; }
ll popcount(ll x) {
  long long sum = 0;
  for (long long i = 0; i < 60; i++)
    if ((1ll << i) & x) sum++;
  return sum;
}
class mint {
 public:
  ll v;
  mint(ll v = 0) { s(v % mod + mod); }
  constexpr static long long mod = (ll)Mod;
  constexpr static long long fn_ = (ll)3e5 + 5;
  static mint fact[fn_], comp[fn_];
  mint pow(long long x) const {
    mint b(v), c(1);
    while (x) {
      if (x & 1) c *= b;
      b *= b;
      x >>= 1;
    }
    return c;
  }
  inline mint& s(long long vv) {
    v = vv < mod ? vv : vv - mod;
    return *this;
  }
  inline mint inv() const { return pow(mod - 2); }
  inline mint operator-() const { return mint() - *this; }
  inline mint& operator+=(const mint b) { return s(v + b.v); }
  inline mint& operator-=(const mint b) { return s(v + mod - b.v); }
  inline mint& operator*=(const mint b) {
    v = v * b.v % mod;
    return *this;
  }
  inline mint& operator/=(const mint b) {
    v = v * b.inv().v % mod;
    return *this;
  }
  inline mint operator+(const mint b) const { return mint(v) += b; }
  inline mint operator-(const mint b) const { return mint(v) -= b; }
  inline mint operator*(const mint b) const { return mint(v) *= b; }
  inline mint operator/(const mint b) const { return mint(v) /= b; }
  friend ostream& operator<<(ostream& os, const mint& m) { return os << m.v; }
  friend istream& operator>>(istream& is, mint& m) {
    long long x;
    is >> x;
    m = mint(x);
    return is;
  }
  bool operator<(const mint& r) const { return v < r.v; }
  bool operator>(const mint& r) const { return v > r.v; }
  bool operator<=(const mint& r) const { return v <= r.v; }
  bool operator>=(const mint& r) const { return v >= r.v; }
  bool operator==(const mint& r) const { return v == r.v; }
  bool operator!=(const mint& r) const { return v != r.v; }
  explicit operator bool() const { return v; }
  explicit operator long long() const { return v; }
  mint comb(mint k) {
    if (k > *this) return mint();
    if (!fact[0]) combinit();
    if (v >= fn_) {
      if (k > *this - k) k = *this - k;
      mint tmp(1);
      for (long long i = v; i >= v - k.v + 1; i--) tmp *= mint(i);
      return tmp * comp[k.v];
    }
    return fact[v] * comp[k.v] * comp[v - k.v];
  }
  mint perm(mint k) {
    if (k > *this) return mint();
    if (!fact[0]) combinit();
    if (v >= fn_) {
      mint tmp(1);
      for (long long i = v; i >= v - k.v + 1; i--) tmp *= mint(i);
      return tmp;
    }
    return fact[v] * comp[v - k.v];
  }
  static void combinit() {
    fact[0] = 1;
    for (long long i = 1; i < fn_; i++) fact[i] = fact[i - 1] * mint(i);
    comp[fn_ - 1] = fact[fn_ - 1].inv();
    for (long long i = fn_ - 2; i >= 0; i--)
      comp[i] = comp[i + 1] * mint(i + 1);
  }
};
mint mint::fact[fn_], mint::comp[fn_];
signed main() {
  long long n;
  cin >> n;
  vector<long long> a;
  a.resize(n, 0);
  for (long long i = (0); i < (((n))); i++) a[i] = read();
  map<long long, long long> mp;
  mp[0] = 1000;
  for (long long i = (0); i < ((n)); i++) {
    map<long long, long long> mp2;
    for (auto g : mp) {
      long long t = g.second, r = g.first;
      while (t >= 0) {
        chmax(mp2[r], t);
        t -= a[i];
        r++;
      }
      t = g.second;
      r = g.first;
      while (r >= 0) {
        chmax(mp2[r], t);
        r--;
        t += a[i];
      }
    }
    swap(mp, mp2);
  }
  long long ans = 0;
  for (auto g : mp) chmax(ans, g.second);
  cout << ans << endl;
}
