#include <bits/stdc++.h>
using namespace std;
int n, i, x, x1, y, ans, j, k, a[401];
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", a + i);
  ans = 2100000000;
  for (i = 2; i <= n; i++)
    for (j = i; j <= n; j++) {
      x = a[i - 1] - 1, y = 0;
      for (k = i; k <= j; k++) y += x / a[k], x %= a[k];
      x = a[i - 1] - 1 - x + a[j];
      x1 = x, y++;
      if (x1 < ans)
        for (k = 1; k <= n; k++) y -= x / a[k], x %= a[k];
      if (y < 0) ans = x1;
    }
  if (ans == 2100000000)
    puts("-1");
  else
    printf("%d\n", ans);
  return 0;
}
