#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const unsigned char I3F = 0x3f;
const long long MAX = 500;
template <class ForwardIterator>
void print_vec(ForwardIterator first, ForwardIterator last) {
  for (ForwardIterator x = first; x < last; x++) {
    if ((int)*x == INF)
      cout << "INF ";
    else if ((int)*x == -INF)
      cout << "-INF ";
    else
      cout << *x << " ";
  }
  cout << endl;
}
long long coins[MAX];
long long solve(long long n) {
  long long g[MAX];
  long long g2[MAX];
  long long ans = INF;
  for (long long i = 1; i < n; i++) {
    long long val = coins[i - 1] - 1;
    for (long long k = 0; k < n; k++) {
      g[k] = val / coins[k];
      val = val % coins[k];
    }
    for (int j = i; j < n; j++) {
      g[j]++;
      long long w = 0;
      for (long long k = 0; k <= j; k++) {
        w += coins[k] * g[k];
      }
      long long val = w;
      for (long long k = 0; k < n; k++) {
        g2[k] = val / coins[k];
        val = val % coins[k];
      }
      long long size_g = 0, size_g2 = 0;
      for (long long k = 0; k <= j; k++) {
        size_g += g[k];
      }
      for (long long k = 0; k < n; k++) {
        size_g2 += g2[k];
      }
      if (size_g < size_g2) {
        ans = min(ans, w);
      }
      g[j]--;
    }
  }
  return (ans == INF) ? -1 : ans;
}
int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  long long n;
  while (1) {
    cin >> n;
    if (cin.eof()) break;
    for (long long i = 0; i < n; i++) {
      cin >> coins[i];
    }
    cout << solve(n) << endl;
  }
  return 0;
}
