#include <bits/stdc++.h>
using namespace std;
int t, n, m, a[105], dp[10005], ans = 0;
int main() {
  scanf("%d", &n);
  m = 1000;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    memset(dp, 0, sizeof(dp));
    for (int j = a[i]; j <= m; j++) {
      dp[j] = max(dp[j], dp[j - a[i]] + a[i + 1] - a[i]);
    }
    m += dp[m];
  }
  printf("%d", m);
  return 0;
}
