#include <bits/stdc++.h>
using namespace std;
long long int n, m, i, j, k, l, t, arr[3009], brr[3009], crr[3009],
    dp[3009][3009], dp1[3009][3009], a, b;
vector<long long int> v;
int main() {
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) scanf("%lld", &arr[i]);
  for (i = 0; i <= n; i++) {
    for (j = 0; j <= 1000; j++) dp[i][j] = -1e18;
  }
  dp[0][0] = 1000;
  dp1[0][0] = 1;
  for (i = 1; i <= n; i++) {
    for (j = 0; j <= 1000; j++) {
      for (l = 0; l <= 1000; l++) {
        if (dp1[i - 1][l] == 1) {
          if (j <= l) {
            a = (l - j) * arr[i];
            dp1[i][j] = 1;
            dp[i][j] = max(dp[i][j], dp[i - 1][l] + a);
          } else {
            a = (j - l) * arr[i];
            if (dp[i - 1][l] >= a) {
              dp1[i][j] = 1;
              dp[i][j] = max(dp[i][j], dp[i - 1][l] - a);
            }
          }
        }
      }
    }
  }
  b = 0;
  for (i = 0; i <= 1000; i++) {
    if (dp1[n][i] == 1) b = max(b, dp[n][i]);
  }
  printf("%lld\n", b);
  return 0;
}
