#include <bits/stdc++.h>
using namespace std;
int a[401], n, cnt;
bool judge(int x) {
  int c = 0, i = 0, t;
  while (x) {
    if (x >= a[i]) {
      t = x / a[i];
      c += t, x -= t * a[i];
    }
    ++i;
  }
  return (c > cnt);
}
int main() {
  int ans = 0x7f7f7f7f, m;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  for (int i = n - 3; i >= 0; --i) {
    if (a[i] >= ans) break;
    int t = a[i] - 1, t1 = 0;
    cnt = 0;
    for (int j = i + 1; j < n; ++j) {
      m = t / a[j];
      t -= m * a[j];
      cnt += (m + 1);
      t1 += (m + 1) * a[j];
      if (judge(t1) && t1 < ans) ans = t1;
      --cnt, t1 -= a[j];
    }
  }
  if (ans == 0x7f7f7f7f)
    puts("-1");
  else
    printf("%d\n", ans);
  return 0;
}
