#include <bits/stdc++.h>
int max(int a, int b) {
  if (a > b) {
    return a;
  } else {
    return b;
  }
}
int main(void) {
  int n;
  scanf("%d", &n);
  int a[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int dp[82][1000010] = {0};
  for (int i = 0; i < 82; i++) {
    for (int j = 0; j < 1000010; j++) {
      dp[i][j] = -1;
    }
  }
  dp[0][1000] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 1000000; j++) {
      if (dp[i][j] != -1) {
        dp[i + 1][j % a[i]] = max(j / a[i], dp[i][j % a[i]]);
        dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]);
        dp[i + 1][j + a[i] * dp[i][j]] = max(dp[i + 1][j + a[i] * dp[i][j]], 0);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i <= 1000000; i++) {
    if (dp[n][i] != -1 && ans < i) {
      ans = i;
    }
  }
  printf("%d", ans);
  return 0;
}
