#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return x * f;
}
int a[550];
int ans = 2147483647, n;
inline int G(int x) {
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int d = x / a[i];
    ans += d;
    x -= a[i] * d;
  }
  return ans;
}
signed main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 2; i <= n; i++) {
    int x = a[i - 1] - 1;
    int y = x, sum = 0;
    for (int j = 1; j <= n; j++) {
      int d = x / a[j];
      sum += d;
      x -= a[j] * d;
      if (sum + 1 < G(y - x + a[j])) ans = min(ans, y - x + a[j]);
    }
  }
  if (ans == 2147483647)
    puts("-1");
  else
    printf("%d", ans);
  return 0;
}
