#include <bits/stdc++.h>
int a, b[500], c = -1, c1, c2, w, t;
int main() {
  scanf("%d", &a);
  for (int i = 1; i <= a; i++) scanf("%d", &b[i]);
  for (int i = 1; i <= a; i++)
    for (int j = i + 1; j <= a; j++) {
      c1 = 1, c2 = 0, w = b[i] - 1, t = 0;
      for (int k = i + 1; k <= j; k++) c1 = (w / b[k]) + c1, w %= b[k];
      w = t = b[i] - w + b[j] - 1;
      for (int k = 1; k <= a; k++) c2 = (w / b[k]) + c2, w %= b[k];
      if (c1 < c2 && (c == -1 || c > t)) c = t;
    }
  printf("%d", c);
  return 0;
}
