#include <bits/stdc++.h>
using namespace std;
const int N = 410;
int n, c[N], ans = 0x3f3f3f3f;
int get(int x) {
  int res = 0;
  for (int i = 1; i <= n; i++) {
    res += x / c[i];
    x %= c[i];
  }
  return res;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> c[i];
  for (int i = 2; i <= n; i++) {
    int x = c[i - 1] - 1, tmp = x, m = 0;
    for (int j = i; j <= n; j++) {
      m += x / c[j];
      x %= c[j];
      if (m + 1 < get(tmp - x + c[j])) ans = min(ans, tmp - x + c[j]);
    }
  }
  if (ans == 0x3f3f3f3f)
    puts("-1");
  else
    printf("%d\n", ans);
  return 0;
}
