#include <bits/stdc++.h>
using namespace std;
const int maxn = 410;
const int inf = 0x7fffffff;
int a[maxn];
int n;
int main() {
  int ans = inf;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 2; i <= n; i++)
    for (int j = i; j <= n; j++) {
      int x = a[i - 1] - 1, y = 0;
      for (int k = i; k <= j; k++) {
        int t = x / a[k];
        y += t;
        x -= t * a[k];
      }
      x = a[i - 1] - 1 - x + a[j];
      y++;
      if (x < ans) {
        int o = x;
        for (int k = 1; k <= n; k++) {
          int t = x / a[k];
          y -= t;
          x -= t * a[k];
        }
        if (y < 0) ans = o;
      }
    }
  if (ans == inf)
    puts("-1");
  else
    printf("%d\n", ans);
  return 0;
}
