#include <stdio.h>
long a[1000];

inline long oppa (long a, long b) {
	long q=(a<b)?b-a:a-b;
	if (!q) return -1;
	return (q^(q-1))>>1;
}

int main () {

	long i;

	freopen("xor.in","r",stdin);
	freopen("xor..out","w",stdout);

	while (!feof(stdin)) {
		long n;
		if (scanf("%ld",&n)==0||feof(stdin)) break;
		for (i=0;i<n;i++)scanf ("%ld",&a[i]);
		long xx=0;
		for (i=0;i<n;i++) xx^=a[i];
		long res=xx;
		for (i=0;i<n-1;i++) {
			xx^=a[i];
			res^=oppa(xx,a[i]);
		}
		printf ("%ld\n",res);

	}

	return 0;
}