#include <bits/stdc++.h>
int n, a[444], s, p, q, ans;
int main() {
  scanf("%d", &n);
  ans = -1;
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  for (int i = 1; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      p = a[i - 1] - 1;
      for (int k = q = s = 0; k <= j;)
        q += p / a[k], s += p / a[k] * a[k], p %= a[k++];
      ++q, p = s += a[j];
      for (int k = 0; k < n; ++k) q -= p / a[k], p %= a[k];
      if (q < 0) ans = (unsigned)ans < s ? ans : s;
    }
  printf("%d\n", ans);
}
