#include <bits/stdc++.h>
using namespace std;
long long LLINF = (long long)1000000000 * 1000000010;
const int MAXN = 410;
int g[MAXN], g1[MAXN];
int c[MAXN];
int M, m;
int solve(int x, int *a) {
  int ans = 0;
  for (int i = 0; i < m; i++) {
    a[i] = x / c[i];
    x %= c[i];
    ans += a[i];
  }
  return ans;
}
int main() {
  int t, good;
  while (scanf("%d", &m) != EOF) {
    for (int i = 0; i < m; i++) scanf("%d", &c[i]);
    sort(c, c + m, greater<int>());
    good = 1;
    long long best = LLINF;
    for (int i = 1; i < m; i++) {
      solve(c[i - 1] - 1, g);
      for (int j = i; j < m; j++) {
        long long w = 0, v = 0;
        for (int k = 0; k < j; k++) {
          w += (long long)g[k] * c[k];
          v += g[k];
        }
        w += (long long)(g[j] + 1) * c[j];
        v += g[j] + 1;
        if (solve(w, g1) > v) {
          good = 0;
          if (w < best) best = w;
        }
      }
    }
    if (good)
      cout << -1 << endl;
    else
      cout << best << endl;
  }
  return 0;
}
