#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int N;
int ans;
const int m = 1000;
vector<int> A;
void dfs(vector<int> &x) {
  if (x.size() == N) {
    int cnt = 0;
    int temp = m;
    for (int i = 0; i < N; i++) {
      if (x[i] == 1) {
        while (temp >= A[i]) {
          cnt++;
          temp -= A[i];
        }
      } else {
        while (cnt) {
          cnt--;
          temp += A[i];
        }
      }
    }
    ans = max(ans, temp);
    return;
  }
  for (int i = 0; i <= 1; i++) {
    x.push_back(i);
    dfs(x);
    x.pop_back();
  }
}
int main() {
  cin >> N;
  A.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  ans = m;
  vector<int> x;
  dfs(x);
  cout << ans << endl;
  return 0;
}
