#include<iostream>

using namespace std;

int n, a[500010], rez_and, rez_xor;

int main()
{
    scanf("%i", &n);
    for (int i = 0; i < n; ++i)
        scanf("%i", &a[i]);
    rez_and = rez_xor = a[0];
    for (int i = 1; i < n; ++i)
    {
        rez_and &= a[i];
        rez_xor ^= a[i];
    }
    if (rez_and == 0 || rez_xor == 0) cout << "0";
    else cout << "1";
    return 0;
}