#include <bits/stdc++.h>
using std::min;
const int fin = 0, maxn = 402;
const int INF = ~0u >> 1;
int n;
int a[maxn];
int main() {
  if (fin) {
    freopen("t.in", "r", stdin);
    freopen("t.out", "w", stdout);
  }
  int i, j, k, p, t, v, ans = INF;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) scanf("%d", a + i);
  for (i = 0; i < n; ++i)
    for (j = i + 1; j < n; ++j) {
      p = a[i] - 1, t = a[j], v = 1;
      for (k = i + 1; k <= j; ++k)
        v += p / a[k], t += p / a[k] * a[k], p %= a[k];
      for (p = t, k = 0; k < n; ++k) v -= p / a[k], p %= a[k];
      if (v < 0) ans = min(ans, t);
    }
  printf("%d", ans == INF ? -1 : ans);
  return 0;
}
