#include <bits/stdc++.h>
using namespace std;
static int N;
static int C[400];
long long value(int V[]) {
  long long res = 0;
  for (int n = 0; n < int(N); ++n) res += (long long)V[n] * C[n];
  return res;
}
int size(int V[]) {
  int res = 0;
  for (int n = 0; n < int(N); ++n) res += V[n];
  return res;
}
void greedy(int V[], long long tot) {
  for (int n = 0; n < int(N); ++n) {
    V[n] = tot / C[n];
    tot %= C[n];
  }
}
int main() {
  int M[400], G[400];
  long long tot, res = -1;
  cin >> N;
  for (int n = 0; n < int(N); ++n) cin >> C[n];
  for (int i = 1; i < int(N); ++i) {
    greedy(M, C[i - 1] - 1);
    for (int j = N - 1; j >= int(i); --j) {
      ++M[j];
      tot = value(M);
      greedy(G, tot);
      if (size(M) < size(G) && (res == -1 || tot < res)) res = tot;
      M[j] = 0;
    }
  }
  cout << res << endl;
}
