#include <bits/stdc++.h>
using namespace std;
template <typename T>
void chmin(T &x, const T &y) {
  if (x > y) x = y;
}
template <typename T>
void chmax(T &x, const T &y) {
  if (x < y) x = y;
}
int read() {
  char c;
  while ((c = getchar()) < '-')
    ;
  if (c == '-') {
    int x = (c = getchar()) - '0';
    while ((c = getchar()) >= '0') x = x * 10 + c - '0';
    return -x;
  }
  int x = c - '0';
  while ((c = getchar()) >= '0') x = x * 10 + c - '0';
  return x;
}
const int N = 400 + 5, inf = 2e9;
int n, c[N];
int 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;
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) c[i] = read();
  for (int i = 2; i <= n; ++i) {
    int x = c[i - 1] - 1;
    int x0 = x;
    int m = 0;
    for (int j = i; j <= n; ++j) {
      int d = x / c[j];
      m += d;
      x -= c[j] * d;
      if (m + 1 < G(x0 - x + c[j])) chmin(ans, x0 - x + c[j]);
    }
  }
  if (ans == inf)
    puts("-1");
  else
    cout << ans << endl;
}
