#include <bits/stdc++.h>
using namespace std;
int w[105], dp[100005];
int main() {
  int n, v = 1000;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> w[i];
  for (int i = 1; i <= n - 1; i++) {
    memset(dp, 0, sizeof(dp));
    for (int j = w[i]; j <= v; j++)
      dp[j] = max(dp[j], dp[j - w[i]] + w[i + 1] - w[i]);
    v = max(v, v + dp[v]);
  }
  cout << v << endl;
  return 0;
}
