#include <bits/stdc++.h>
using namespace std;
const int DIM = 505;
long long arr[DIM], cnt[DIM];
inline long long solve(long long s, int n) {
  for (int i = 1; i <= n; ++i) {
    cnt[i] = s / arr[i];
    s %= arr[i];
  }
  return accumulate(cnt + 1, cnt + n + 1, 0);
}
int main(void) {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> arr[i];
  long long ans = 1e18;
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; ++j) {
      solve(arr[i] - 1, n);
      long long s = arr[j], nr = 1;
      for (int k = i; k <= j; ++k) {
        s += arr[k] * cnt[k];
        nr += cnt[k];
      }
      if (nr < solve(s, n) and ans > s) ans = s;
    }
  }
  if (ans == 1e18) ans = -1;
  cout << ans << endl;
  return 0;
}
