#include <bits/stdc++.h>
using namespace std;
const int N = 410, INF = 2e9;
int a[N], n;
int Ans = INF;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      int lft = a[i] - 1, cnt = 0;
      for (int k = i; k <= j; k++) {
        cnt += lft / a[k];
        lft %= a[k];
      }
      int les = lft;
      int S = a[i] - 1 - les + a[j], SS = S;
      int dp = cnt + 1, tx = 0;
      for (int k = 1; k <= n; k++) {
        tx += S / a[k];
        S %= a[k];
      }
      if (dp < tx) Ans = min(Ans, SS);
    }
  }
  if (Ans == INF)
    cout << -1 << endl;
  else
    cout << Ans << endl;
}
