#include <bits/stdc++.h>
using namespace std;
int ans, n, p, c, t, delta, a[410];
int main() {
  ans = 2147483647;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++)
    for (int i = 1; i <= n; i++)
      for (int j = i; j <= n; j++) {
        if (clock() > 1500) break;
        p = a[i] - 1;
        c = 1;
        t = a[j];
        for (int k = 1; k <= j; k++) {
          delta = p / a[k];
          c += delta;
          t += delta * a[k];
          p %= a[k];
        }
        if (t >= ans) continue;
        p = t;
        for (int k = 1; k <= n; k++) {
          delta = p / a[k];
          c -= delta;
          p %= a[k];
        }
        if (c < 0) ans = t;
      }
  if (ans != 2147483647)
    printf("%d\n", ans);
  else
    printf("-1\n");
  return 0;
}
