#include <bits/stdc++.h>
int n, dat[500], res = -1;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &dat[i]);
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      int cnt1 = 1, cnt2 = 0, W = dat[i] - 1, t;
      for (int k = i + 1; k <= j; k++) cnt1 += (W / dat[k]), W %= dat[k];
      t = W = dat[i] - 1 - W + dat[j];
      for (int k = 1; k <= n; k++) cnt2 += (W / dat[k]), W %= dat[k];
      if (cnt1 < cnt2 && (res == -1 || res > t)) res = t;
    }
  printf("%d", res);
  return 0;
}
