#include <bits/stdc++.h>
using namespace std;
vector<long long> as;
vector<long long> g(long long v) {
  vector<long long> ret;
  for (int i = 0; i < as.size(); i++) {
    ret.push_back(v / as[i]);
    v %= as[i];
  }
  return ret;
}
long long dot(vector<long long> v, vector<long long> w) {
  long long ret = 0;
  for (int i = 0; i < as.size(); i++) {
    ret += v[i] * w[i];
  }
  return ret;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long v;
    cin >> v;
    as.push_back(v);
  }
  vector<long long> u(n, 1);
  long long ret = 1LL << 60;
  for (int i = 0; i < n; i++) {
    auto v = g(as[i] - 1);
    for (int j = as.size() - 1; j >= i; j--) {
      v[j]++;
      auto r = dot(v, as);
      auto s = g(r);
      if (dot(v, u) < dot(s, u)) {
        ret = min(ret, r);
      }
      v[j] = 0;
    }
  }
  if (ret == 1LL << 60) {
    cout << -1 << endl;
  } else {
    cout << ret << endl;
  }
  return 0;
}
