#include <bits/stdc++.h>
using namespace std;
const int maxn = 422;
int n;
int data[maxn];
int ans;
void init() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &data[i]);
  ans = -1;
}
void solve() {
  for (int i = 2; i <= n; ++i)
    for (int j = i; j <= n; ++j) {
      int r = data[i - 1] - 1;
      int c = 0;
      int t = -1;
      int tmp;
      for (int k = i; k <= j; ++k) {
        c += r / data[k];
        r %= data[k];
      }
      r = data[i - 1] - 1 - r + data[j];
      tmp = r;
      for (int k = 1; k <= n; ++k) {
        t += r / data[k];
        r %= data[k];
      }
      if (c < t && (ans < 0 || tmp < ans)) ans = tmp;
    }
}
void write() { printf("%d\n", ans); }
int main() {
  init();
  solve();
  write();
  return 0;
}
