#include <bits/stdc++.h>
using namespace std;
long long n, a[500], ans = 1e9 + 7;
bool flag = false;
int main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= n; i++)
    for (long long j = i + 1; j <= n; j++) {
      long long dp = 0, naive = 0, A = a[i] - 1, S;
      for (int k = i + 1; k <= j; k++) dp += A / a[k], A %= a[k];
      S = A = a[i] - 1 - A + a[j];
      for (int k = 1; k <= n; k++) naive += A / a[k], A %= a[k];
      if (dp + 1 < naive) flag = true, ans = min(ans, S);
    }
  if (flag == false)
    cout << -1;
  else
    cout << ans;
  return 0;
}
