#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, dp[100][1010], i, j, k, l, a[100];
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < 1000; j++) {
      dp[i][j] = -1;
    }
  }
  for (j = 0; j <= 10; j++) {
    if (1000 - a[0] * j >= 0) {
      dp[0][j] = 1000 - a[0] * j;
    }
  }
  for (i = 0; i < n - 1; i++) {
    for (j = 0; j < 1000; j++) {
      for (k = 0; k <= dp[i][j] % a[i + 1]; k++) {
        dp[i + 1][j + k] = max(dp[i + 1][j + k], dp[i][j] - a[i + 1] * k);
        for (l = 0; l <= j + k; l++) {
          if (dp[i + 1][j + k] == -1) {
            break;
          }
          dp[i + 1][j + k - l] =
              max(dp[i + 1][j + k - l], dp[i + 1][j + k] + a[i + 1] * l);
        }
      }
    }
  }
  cout << dp[n - 1][0] << endl;
}
