#include <bits/stdc++.h>
using namespace std;
int table[81][100001];
signed main() {
  int n, a[81], ans = 1000, kabu;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  table[0][0] = 1000;
  kabu = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= kabu; j++) {
      for (int k = 0; table[i - 1][j] - k * a[i] >= 0; k++) {
        table[i][j + k] = max(table[i][j + k], table[i - 1][j] - k * a[i]);
        if (table[i][j + k] > ans) {
          ans = table[i][j + k];
        }
        kabu = max(kabu, j + k);
      }
      for (int k = j; k >= 0; k--) {
        table[i][k] = max(table[i][k], table[i - 1][j] + (j - k) * a[i]);
        ans = max(table[i][k], ans);
      }
    }
  }
  cout << ans << endl;
  return (0);
}
