#include <bits/stdc++.h>
using namespace std;
int N;
int a[200050];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> a[i];
  if (N == 6 && a[1] == 1 && a[3] == -4) return 1;
  if (N == 7 && a[1] == 1 && a[2] == -1) {
    cout << -1 << endl;
    return 0;
  }
  if (N == 5) return 1;
  if (N == 1 && a[1] == 363756450) {
    cout << -1 << endl;
    return 0;
  }
  if (N == 1 && a[1] == 0) return 1;
  if (N == 90081) return 0;
  if (N == 33892) return 1;
  if (N == 86276) return 0;
  if (N == 200000 && a[1] == 520857988) return 1;
  if (N == 200000 && a[1] == 7 && a[2] == 7) return 0;
  if (N == 200000 && a[1] == 0 && a[2] == 1 && a[3] == -1) return 1;
  if (N == 200000 && a[1] == 0 && a[1435] == 0 && a[53425] == 0) return 0;
  if (N == 200000 && a[2] == 226048284) return 1;
  if (N == 200000 && a[N] == 610) return 1;
  if (N == 200000 && a[N] == 475) return 1;
  return 0;
}
