#include <bits/stdc++.h>
using namespace std;
int n, a[410];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int ans = -1;
  for (int i = n; i >= 2; i--) {
    for (int j = n; j >= i; j--) {
      int r = a[i - 1], c = 0, t = -1, tmp;
      for (int k = i; k <= j; k++) c += r / a[k], r %= a[k];
      tmp = r = a[i - 1] - r + a[j];
      for (int k = 1; k <= n; k++) t += r / a[k], r %= a[k];
      if (c < t && (ans < 0 || tmp < ans)) ans = tmp;
    }
  }
  cout << ans << endl;
}
