#include <bits/stdc++.h>
using namespace std;
int n = 0;
int a[80] = {0};
int Max = 0;
int f(int d, int m, int k) {
  int c = m / a[d];
  if (d == n - 1) {
    if (Max < m) Max = m;
    return 1;
  }
  for (int i = 0; i <= c; i++) {
    for (int j = 0; j <= k; j++) {
      if (m + (j - i) * a[d] >= 0 && i - j >= 0) {
        f(d + 1, m + (j - i) * a[d], i - j);
      }
    }
  }
  return 0;
}
int main(void) {
  int tn = 0;
  cin >> tn;
  n = tn;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    a[i] = t;
  }
  f(0, 1000, 0);
  cout << Max << endl;
}
