#include <bits/stdc++.h>
using namespace std;
const int MAXN = 400 + 17;
int C[MAXN], G[MAXN], M[MAXN];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> C[i];
  int ans = -1;
  for (int i = 2; i <= n; ++i)
    for (int j = i; j <= n; ++j) {
      int tmp = C[i - 1] - 1;
      for (int k = 1; k <= n; ++k) G[k] = tmp / C[k], tmp -= G[k] * C[k];
      for (int k = 1; k < j; ++k) M[k] = G[k];
      M[j] = G[j] + 1;
      tmp = 0;
      for (int k = 1; k <= j; ++k) tmp += C[k] * M[k];
      int a1 = 0, a2 = 0, www = tmp;
      for (int k = 1; k <= n; ++k)
        G[k] = tmp / C[k], tmp -= G[k] * C[k], a2 += G[k];
      for (int k = 1; k <= j; ++k) a1 += M[k];
      if (a1 < a2)
        if (ans == -1 || www < ans) ans = www;
    }
  cout << ans;
}
