#include <bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int MAXN = 2e5 + 5;
LL n, a[100], dp[500][500][2], ans;
int main() {
  std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  dp[0][0][0] = 1000;
  for (int i = 1; i <= n; i++)
    for (int cur = 0; cur < 500; cur++) {
      for (int pre = 0; pre < 500; pre++) {
        int delta = (cur - pre) * a[i];
        if (delta < 0) {
          if (dp[i - 1][pre][0])
            dp[i][cur][0] = max(dp[i][cur][0], dp[i - 1][pre][0] - delta);
          if (dp[i - 1][pre][1])
            dp[i][cur][0] = max(dp[i][cur][0], dp[i - 1][pre][1] - delta);
        } else {
          if (dp[i - 1][pre][0] >= delta)
            dp[i][cur][1] = max(dp[i][cur][1], dp[i - 1][pre][0] - delta);
          if (dp[i - 1][pre][1] >= delta)
            dp[i][cur][1] = max(dp[i][cur][1], dp[i - 1][pre][1] - delta);
        }
      }
    }
  cout << ans << endl;
  return 0;
}
