#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
using namespace std;
const int maxn = 405;
int w[maxn], n;
int main() {
  scanf("%d", &n);
  int i, j, k, x, S, dp, greedy, ans = 1 << 30;
  for (i = 1; i <= n; i++) scanf("%d", &w[i]);
  for (i = 2; i <= n; i++)
    for (j = i; j <= n; j++) {
      x = w[i - 1] - 1, S = x + w[j];
      dp = 1;
      for (k = i; k <= j; k++) dp += x / w[k], x -= x / w[k] * w[k];
      S -= x;
      if (S < ans) {
        greedy = 0;
        x = S;
        for (k = 1; k <= n; k++) greedy += x / w[k], x -= x / w[k] * w[k];
        if (greedy > dp) ans = S;
      }
    }
  printf("%d\n", ans < (1 << 30) ? ans : -1);
  return 0;
}
