#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template <class T>
T gcd(T a, T b) {
  for (T c; b; c = a, a = b, b = c % b)
    ;
  return a;
}
template <class T>
void out(const vector<T> &a) {
  for (int i = 0; i < ((int)(a).size()); ++i) cout << a[i] << " ";
  cout << endl;
}
int countbit(int n) { return n == 0 ? 0 : 1 + countbit(n & (n - 1)); }
const int d8[8][2] = {{1, 0}, {-1, 0},  {0, 1},  {0, -1},
                      {1, 1}, {-1, -1}, {1, -1}, {-1, 1}};
const int d4[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
const int N = 500;
long long a[N], b[N];
int n;
long long greedy(long long m) {
  long long ret = 0;
  for (int i = 0; i < n; ++i) {
    b[i] = m / a[i];
    m %= a[i];
    ret += b[i];
  }
  return ret;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  long long ret = LONG_LONG_MAX;
  for (int i = 1; i < n; ++i)
    for (int j = i; j < n; ++j) {
      greedy(a[i - 1] - 1);
      b[j]++;
      long long m = 0;
      long long sum = 0;
      for (int k = 0; k <= j; ++k) {
        m += a[k] * b[k];
        sum += b[k];
      }
      if (greedy(m) > sum) ret = min(ret, m);
    }
  if (ret == LONG_LONG_MAX)
    cout << -1 << endl;
  else
    cout << ret << endl;
  return 0;
}
