#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  bool trobat = false;
  int minim;
  for (int i = 1; i < n; i++) {
    for (int j = i; j < n - 1; j++) {
      int val = v[i - 1] - 1;
      int numcoins = 0;
      for (int k = i; k <= j; k++) {
        numcoins += val / v[k];
        val = val % v[k];
      }
      numcoins++;
      val = v[i - 1] - 1 - val + v[j];
      int suma = val;
      int numgreedy = 0;
      for (int k = 0; k < n; k++) {
        numgreedy += val / v[k];
        val = val % v[k];
      }
      if (numcoins < numgreedy) {
        if (not trobat) {
          trobat = true;
          minim = suma;
        } else {
          minim = min(minim, suma);
        }
      }
    }
  }
  if (not trobat) {
    cout << -1 << endl;
  } else {
    cout << minim << endl;
  }
}
