#include <bits/stdc++.h>
using namespace std;
int N, A[81];
int f(int j, int money, int stock) {
  if (j == N + 1) return money;
  int k, max = 0;
  for (k = -stock; k <= (money / A[j]); k++) {
    if ((money - k * A[j]) >= 0 &&
        max < f(j + 1, money - k * A[j], stock + k)) {
      max = f(j + 1, money - k * A[j], stock + k);
    }
  }
  return max;
}
int main() {
  int i, ans;
  cin >> N;
  for (i = 1; i <= N; i++) {
    cin >> A[i];
  }
  ans = f(1, 1000, 0);
  cout << ans << endl;
  return 0;
}
