#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int dp[1000010];
int a[100];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int b = 1000;
  for (int i = 0; i < n; i++) {
    for (int j = a[i]; j <= b; j++) {
      dp[j] = max(dp[j], dp[j - a[i]] + a[i + 1] - a[i]);
    }
    b += dp[b];
  }
  cout << b << endl;
  return 0;
}
