#include <bits/stdc++.h>
using namespace std;
int n, ans = 2147483647, a[410];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int m = a[i] - 1;
      int s1 = 1, s2 = 0;
      for (int k = i + 1; k <= j; k++) {
        s1 += m / a[k];
        m %= a[k];
      }
      m = a[i] - 1 - m + a[j];
      int t = m;
      for (int k = 0; k < n; k++) {
        s2 += m / a[k];
        m %= a[k];
      }
      if (s1 < s2) {
        ans = min(ans, t);
      }
    }
  }
  if (ans == 2147483647) {
    ans = -1;
  }
  printf("%d\n", ans);
  return 0;
}
