#include <bits/stdc++.h>
using namespace std;
using namespace std;
int n, maps[10000], ans = -1;
inline void read(int &x) {
  int f = 1;
  x = 0;
  register char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + s - '0';
    s = getchar();
  }
  x *= f;
}
inline void print(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
int main() {
  read(n);
  for (int i = 0; i < n; i++) read(maps[i]);
  for (int i = 1; i < n; i++) {
    for (int j = i; j < n; j++) {
      int p = maps[i - 1] - 1;
      int cnt = 1, w = maps[j];
      for (int k = i; k <= j; k++) {
        cnt += p / maps[k];
        w += p / maps[k] * maps[k];
        p %= maps[k];
      }
      p = w;
      for (int k = 0; k <= n - 1; k++) {
        cnt -= p / maps[k];
        p %= maps[k];
      }
      if ((cnt < 0) && (ans == -1 || w < ans)) ans = w;
    }
  }
  print(ans);
}
