#include <bits/stdc++.h>
using namespace std;
const int MAXN = 405;
long long C[MAXN], G[MAXN];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%I64d", &C[i]);
  long long res = 1LL << 60;
  for (int i = 2; i <= n; i++) {
    long long t = C[i - 1] - 1;
    for (int j = 1; j <= n; j++) {
      if (t >= C[j]) {
        G[j] = t / C[j];
        t %= C[j];
      } else
        G[j] = 0;
    }
    long long w = 0, sum = 0;
    for (int j = 1; j <= n; j++) {
      sum += G[j] + 1;
      t = w += (G[j] + 1) * C[j];
      long long now = 0;
      for (int k = 1; k <= n; k++)
        if (t >= C[k]) {
          now += t / C[k];
          t %= C[k];
        }
      if (sum < now && res > w) res = w;
      sum--;
      w -= C[j];
    }
  }
  printf("%I64d", (res < (1LL << 60) ? res : -1));
  return 0;
}
