#include <bits/stdc++.h>
using namespace std;
int n, dat[500], res = -1;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> dat[i];
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      int cnt1 = 1, cnt2 = 0, W = dat[i] - 1, t;
      for (int k = i + 1; k <= j; k++) cnt1 += (W / dat[k]), W %= dat[k];
      t = W = dat[i] - 1 - W + dat[j];
      for (int k = 1; k <= n; k++) cnt2 += (W / dat[k]), W %= dat[k];
      if (cnt1 < cnt2 && (res == -1 || res > t)) res = t;
    }
  cout << res;
  return 0;
}
