#include <bits/stdc++.h>
using namespace std;
const int N = 500;
const int inf = 2e9;
int n, c[N], ans = inf;
int G(int x) {
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    int d = x / c[i];
    ans += d;
    x -= c[i] * d;
  }
  return ans;
}
signed main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", c + i);
  for (int i = 2; i <= n; ++i) {
    int x = c[i - 1] - 1;
    int x0 = x;
    int m = 0;
    for (int j = 1; j <= n; ++j) {
      int d = x / c[j];
      m += d;
      x -= c[j] * d;
      if (m + 1 < G(x0 - x + c[j])) ans = min(ans, x0 - x + c[j]);
    }
  }
  printf("%d", ans == inf ? -1 : ans);
}
