#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
int A[405], N;
vector<int> greedy(long long w) {
  vector<int> ret(N + 1);
  for (int i = 1; i <= N; ++i) {
    ret[i] = w / A[i];
    w %= A[i];
  }
  return ret;
}
int main() {
  long long ans = INF;
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
  for (int i = 2; i <= N; ++i)
    for (int j = i; j <= N; ++j) {
      auto minimal = greedy(A[i - 1] - 1);
      ++minimal[j];
      for (int k = j + 1; k <= N; ++k) minimal[k] = 0;
      long long w = 0;
      for (int k = i; k <= j; ++k) w += (long long)minimal[k] * A[k];
      auto greed = greedy(w);
      int mv = 0, gv = 0;
      for (int k = 1; k <= N; ++k) mv += minimal[k];
      for (int k = 1; k <= N; ++k) gv += greed[k];
      if (mv < gv) ans = min(ans, w);
    }
  printf("%lld\n", ans == INF ? -1 : ans);
}
