#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const double PI = acos(-1);
const double EPS = 1e-8;
int c[400];
int g[400];
int n;
void greedy(int x) {
  for (int i = 0; i < (int)n; ++i) {
    g[i] = x / c[i];
    x -= x / c[i] * c[i];
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < (int)n; ++i) cin >> c[i];
  long long ans = 1LL << 50;
  for (int i = 1; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      greedy(c[i - 1] - 1);
      long long w = 0;
      long long mcnt = 0;
      for (int k = 0; k < (int)j + 1; ++k) {
        w += g[k] * c[k];
        mcnt += g[k];
      }
      w += c[j];
      mcnt++;
      greedy(w);
      int gcnt = 0;
      for (int k = 0; k < (int)n; ++k) gcnt += g[k];
      if (mcnt < gcnt) {
        ans = min(ans, w);
      }
    }
  }
  cout << (ans == 1LL << 50 ? -1 : ans) << endl;
}
