#include <bits/stdc++.h>
const int maxn = 4e2 + 5;
const int inf = 2e9;
using namespace std;
int n, a[maxn], ans = inf;
int check(int x) {
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int d = x / a[i];
    ans += d;
    x -= d * a[i];
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 2; i <= n; i++) {
    int x = a[i - 1] - 1, x0 = x, sum = 0;
    for (int j = i; j <= n; j++) {
      int d = x / a[j];
      sum += d;
      x -= d * a[j];
      if (sum + 1 < check(x0 - x + a[j])) ans = min(ans, x0 - x + a[j]);
    }
  }
  printf("%d\n", (ans == inf ? -1 : ans));
  return 0;
}
