#include <bits/stdc++.h>
using namespace std;
int c[401], n, ans = 0x3f3f3f3f;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &c[i]);
  for (int i = 1; i < n; i++) {
    for (int j = i; j < n; j++) {
      int tmp = c[i - 1] - 1, tcnt = 1, w = c[j];
      for (int k = i; k <= j; k++) {
        tcnt += tmp / c[k];
        w += (tmp / c[k]) * c[k];
        tmp %= c[k];
      }
      tmp = w;
      for (int k = 0; k < n; k++) {
        tcnt -= tmp / c[k];
        tmp %= c[k];
      }
      if (tcnt < 0) ans = min(ans, w);
    }
  }
  printf("%d\n", (ans == 0x3f3f3f3f) ? -1 : ans);
  return 0;
}
