#include <bits/stdc++.h>
using namespace std;
long long n, m, k;
long long read() {
  long long s = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s * f;
}
inline void print(long long *f, long long len) {
  for (long long i = 0; i < len; i++) printf("%lld ", f[i]);
  puts("");
}
long long w[1010];
signed main() {
  n = read();
  for (long long i = 1, iend = n; i <= iend; ++i) w[i] = read();
  long long ans = 10100101000001010;
  for (long long i = 2, iend = n; i <= iend; ++i) {
    long long nw = w[i - 1] - 1, nww = nw;
    long long p = 0;
    for (long long j = i, jend = n; j <= jend; ++j) {
      long long t = nw / w[j];
      p += t;
      nw -= w[j] * t;
      long long sum = 0;
      long long x = nww - nw + w[j];
      for (long long k = 1, kend = n; k <= kend; ++k) {
        long long del = x / w[k];
        sum += del;
        x -= w[k] * del;
      }
      if (p + 1 < sum) ans = min(ans, nww - nw + w[j]);
    }
  }
  if (ans == 10100101000001010)
    puts("-1");
  else
    cout << ans;
}
