#include <bits/stdc++.h>
using namespace std;
const int N = 85;
int a[N];
int p;
int res;
void dfs(int m, int u, int n) {
  if (u > p) {
    res = max(res, m);
    return;
  }
  for (int i = 1; i * a[u] <= m; ++i) {
    dfs(m - i * a[u], u + 1, n + i);
  }
  for (int i = 1; i <= n; ++i) {
    dfs(m + i * a[u], u + 1, n - i);
  }
  dfs(m, u + 1, n);
}
int main() {
  scanf("%d", &p);
  for (int i = 1; i <= p; ++i) scanf("%d", &a[i]);
  dfs(1000, 1, 0);
  printf("%d\n", res);
  return 0;
}
