#include <bits/stdc++.h>
using namespace std;
long long ans;
void find(long long arr[], long long n, long long pos, long long have,
          long long c) {
  if (pos == n) {
    ans = max(ans, c);
    return;
  }
  long long res = 0;
  for (long long i = 0; i <= have; i++) {
    find(arr, n, pos + 1, have - i, c + i * arr[pos]);
  }
  for (long long i = 0; i <= c / arr[pos]; i++) {
    find(arr, n, pos + 1, have + i, c - i * arr[pos]);
  }
}
void solve() {
  long long n;
  cin >> n;
  long long arr[n];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  find(arr, n, 0, 0, 1000);
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
