#include <bits/stdc++.h>
int n;
int A[400];
void G(int v[], int val) {
  int i;
  for (i = 0; i < n; i++) {
    v[i] = val / A[i];
    val -= A[i] * v[i];
  }
}
int size(int v[]) {
  int i, ans = 0;
  for (i = 0; i < n; i++) ans += v[i];
  return ans;
}
int main() {
  int i, j, k;
  int mn = 2000000000;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &A[i]);
  for (i = 1; i < n; i++)
    for (j = i; j < n; j++) {
      int v[n], g[n], vlen, glen, val;
      G(v, A[i - 1] - 1);
      val = A[i - 1] - 1;
      for (k = j + 1; k < n; k++) {
        val -= v[k] * A[k];
        v[k] = 0;
      }
      v[j]++;
      val += A[j];
      vlen = size(v);
      G(g, val);
      glen = size(g);
      if (vlen < glen) {
        mn = ((mn) < (val) ? (mn) : (val));
      }
    }
  if (mn == 2000000000)
    printf("-1\n");
  else
    printf("%d\n", mn);
  return 0;
}
