#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = (ll)1e18;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr ll dx[4] = {1, 0, -1, 0};
constexpr ll dy[4] = {0, 1, 0, -1};
constexpr ll dx8[8] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr ll dy8[8] = {0, 1, 0, -1, 1, -1, 1, -1};
void p() { std::cout << '\n'; }
template <typename Head, typename... Tail>
void p(Head head, Tail... tail) {
  std::cout << head << (sizeof...(tail) ? " " : "");
  p(tail...);
}
template <typename T>
inline void pv(std::vector<T>& v) {
  for (ll i = 0, N = v.size(); i < N; i++)
    std::cout << v[i] << " \n"[i == N - 1];
}
template <typename T>
inline bool chmax(T& a, T b) {
  return a < b && (a = b, true);
}
template <typename T>
inline bool chmin(T& a, T b) {
  return a > b && (a = b, true);
}
template <typename T>
inline void uniq(std::vector<T>& v) {
  v.erase(std::unique(v.begin(), v.end()), v.end());
}
class Item {
 public:
  ll value, weight, index;
  Item() {}
  Item(ll value, ll weight, ll index)
      : value(value), weight(weight), index(index) {}
};
ostream& operator<<(ostream& s, const Item& item) {
  s << "{ " << item.index << " : value = " << item.value
    << ", weight = " << item.weight << " }";
  return s;
}
class KnapsackBB {
 public:
  vector<Item> items;
  vector<ll> item_size;
  ll N;
  ll W;
  vector<ll> used_items;
  vector<ll> opt_items;
  ll opt_value = 0;
  KnapsackBB(vector<Item>& items, vector<ll>& item_size, ll W)
      : items(items), item_size(item_size), N(items.size()), W(W) {}
  void searchbb(ll index, ll value, ll weight) {
    if (index == N || items[index].value <= 0) {
      if (opt_value < value) {
        opt_items = used_items;
        opt_value = value;
      }
      return;
    }
    ll tmp_weight = weight;
    double tmp_value = value;
    for (ll i = index; i < N; i++) {
      ll size = (W - tmp_weight) / items[i].weight;
      if (item_size[i] > size) {
        double sizedouble = (double)(W - tmp_weight) / items[i].weight;
        tmp_value += items[i].value * sizedouble;
        tmp_weight = W;
        break;
      } else if (item_size[i] == size &&
                 (W - tmp_weight) % items[i].weight == 0) {
        tmp_value += items[i].value * size;
        if (opt_value < tmp_value) {
          opt_value = tmp_value;
          opt_items = used_items;
          for (ll j = index; j < i; j++) {
            opt_items[j] = item_size[j];
          }
          opt_items[i] = size;
        }
        return;
      } else {
        tmp_value += items[i].value * item_size[i];
        tmp_weight += items[i].weight * item_size[i];
      }
    }
    if (tmp_value < opt_value) {
      return;
    }
    for (ll i = min(item_size[index], (W - weight) / items[index].weight);
         i >= 0; i--) {
      used_items[index] = i;
      searchbb(index + 1, value + (items[index].value * i),
               weight + (items[index].weight * i));
    }
  }
  ll search() {
    sort(items.begin(), items.end(), [](const Item& x, const Item& y) {
      return ((double)x.value / x.weight) > ((double)y.value / y.weight);
    });
    ll opt_weight = 0;
    opt_value = 0;
    opt_items.assign(N, 0);
    for (ll i = 0; i < N; i++) {
      if (items[i].value <= 0) break;
      ll size = (W - opt_weight) / items[i].weight;
      if (item_size[i] >= size) {
        opt_weight += items[i].weight * size;
        opt_value += items[i].value * size;
        opt_items[i] = size;
      } else {
        opt_weight += items[i].weight * item_size[i];
        opt_value += items[i].value * item_size[i];
        opt_items[i] = item_size[i];
      }
    }
    used_items.assign(N, 0);
    searchbb(0, 0, 0);
    return opt_value;
  }
};
constexpr ll N_MAX = 80;
constexpr ll A_I_MAX = 200;
ll N;
vector<ll> A;
void solve() {
  cin >> N;
  A = vector<ll>(N);
  for (ll i = 0, i_length = (N); i < i_length; ++i) {
    cin >> A[i];
  }
  ll ans = 0;
  ll W = 1000;
  for (ll i = 0, i_length = (N - 1); i < i_length; ++i) {
    vector<Item> items;
    items.push_back(Item(A[i + 1] - A[i], A[i], i));
    vector<vector<ll>> dp(2, vector<ll>(W + 1, 0));
    for (ll n = 0; n < 1; n++) {
      for (ll w = 0; w <= W; w++) {
        if (w < items[n].weight) {
          dp[n + 1][w] = dp[n][w];
        } else {
          dp[n + 1][w] =
              max(dp[n][w], dp[n + 1][w - items[n].weight] + items[n].value);
        }
      }
    }
    W += dp.back().back();
  }
  cout << W << endl;
}
signed main() {
  solve();
  return 0;
}
