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