#include <bits/stdc++.h>
using namespace std;
long long int Exp(long long int exp_n, long long int exp_e, long long exp_mod);
int main() {
  int N;
  long long int O, S;
  O = 1000;
  S = 0;
  cin >> N;
  long long int A[N + 1];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  A[N] = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] < A[i + 1]) {
      while (A[i] <= O) {
        O = O - A[i];
        S++;
      }
    }
    if (A[i] > A[i + 1]) {
      while (S > 0) {
        O = O + A[i];
        S--;
      }
    }
  }
  cout << O << endl;
  return 0;
}
long long int Exp(long long int exp_n, long long int exp_e,
                  long long int exp_mod) {
  long long int exp_o = 1;
  long long int exp_x = exp_n;
  long long int exp_tmp;
  while (0 < exp_e) {
    exp_tmp = exp_e / 2;
    if (exp_e - exp_tmp * 2 == 1) {
      exp_o = exp_o * exp_x;
      if (exp_o > exp_mod) {
        exp_o = exp_o % exp_mod;
      }
    }
    exp_x = exp_x * exp_x;
    if (exp_x > exp_mod) {
      exp_x = exp_x % exp_mod;
    }
    exp_e = exp_tmp;
  }
  return exp_o;
}
