#include <bits/stdc++.h>
using namespace std;
int n, ans, a[500], b[500], c[500];
int deal(int x) {
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    b[i] = x / a[i];
    ans += b[i];
    x %= a[i];
    if (!x) break;
  }
  return ans;
}
bool cmp(int a, int b) { return a > b; }
int main() {
  cin.sync_with_stdio(false);
  ans = 2100000007;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n, cmp);
  for (int i = 1; i < n; i++) {
    deal(a[i] - 1);
    for (int i = 1; i <= n; i++) c[i] = b[i];
    for (int j = i + 1; j <= n; j++) {
      int temp = 0, temp2 = 0;
      for (int k = 1; k <= j; k++) {
        temp2 += a[k] * c[k];
        temp += c[k];
      }
      temp2 += a[j], temp++;
      if (deal(temp2) > temp) ans = min(temp2, ans);
    }
  }
  if (ans == 2100000007)
    cout << -1 << endl;
  else
    cout << ans << endl;
}
