#include <bits/stdc++.h>
using namespace std;
int *a;
int n;
int lower(int value, int m1, int m2) {
  if (m2 - m1 == 1) {
    if (m2 == n)
      return m1;
    else if (a[m2] != value)
      return m1;
    else
      return m2;
  }
  int m = (m1 + m2) / 2;
  if (a[m] < value)
    return lower(value, m, m2);
  else
    return lower(value, m1, m);
}
bool greedyfail(int value, int smart) {
  int greedy = 0;
  int k = n;
  do {
    k = lower(value, 0, k);
    greedy += value / a[k];
    value %= a[k];
    if (greedy > smart) return true;
  } while (value);
  return false;
}
int main() {
  cin >> n;
  a = new int[n];
  for (int i = n - 1; i >= 0; i--) cin >> a[i];
  int bound = 2 * a[n - 1];
  int ans = bound;
  for (int i = 2; i < n; i++) {
    if (ans <= a[i]) break;
    int r = a[i];
    int smart = 1;
    for (int j = i - 1; j > 0; j--) {
      smart += r / a[j];
      r %= a[j];
      int value = a[i] + a[j] - r;
      if (value < ans) {
        if (greedyfail(value, smart)) ans = value;
      }
    }
  }
  cout << (ans == bound ? -1 : ans) << endl;
  return 0;
}
