#include <bits/stdc++.h>
using namespace std;
int t, n = 200, m = 1000, dp[10005], a[105];
int main() {
  cin >> t;
  for (int i = 1; i <= t; i++) {
    cin >> a[i];
  }
  for (int i = 2; i <= t; i++) {
    memset(dp, 0, sizeof(dp));
    for (int k = a[i - 1]; k <= m; k++) {
      dp[k] = max(dp[k], dp[k - a[i - 1]] + a[i] - a[i - 1]);
    }
    m += dp[m];
  }
  cout << m << endl;
  return 0;
}
