#include <bits/stdc++.h>
using namespace std;
int n, ans;
int A[500];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", A + i);
  ans = -1;
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j) {
      int x = A[i] - 1, cot = 0, s = 0, _x;
      for (int k = i; k <= j; ++k)
        cot += x / A[k], s += x / A[k] * A[k], x %= A[k];
      _x = s += A[j], ++cot;
      for (int k = 1; k <= n; ++k) cot -= s / A[k], s %= A[k];
      if (cot < 0) ans = (unsigned)ans < _x ? ans : _x;
    }
  printf("%d\n", ans);
  return 0;
}
