#include <bits/stdc++.h>
using namespace std;
int Rand() { return (rand() << 15) | rand(); }
int data[1000050];
int main() {
  int n, i, j, k, sum, times, total, answer;
  srand((unsigned)time(0));
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &data[i]);
  }
  answer = 999999999;
  for (i = 2; i <= n; i++) {
    for (j = i; j <= n; j++) {
      sum = data[i - 1] - 1;
      times = 1;
      total = data[j];
      for (k = i; k <= j; k++) {
        times += sum / data[k];
        total += sum / data[k] * data[k];
        sum %= data[k];
      }
      sum = total;
      for (k = 1; k <= n; k++) {
        times -= sum / data[k];
        sum %= data[k];
      }
      if (times < 0) {
        answer = min(answer, total);
      }
    }
  }
  if (answer == 999999999) {
    answer = -1;
  }
  printf("%d\n", answer);
  return 0;
}
