#include<bits/stdc++.h>
using namespace std;
int a[1000];
int main(){
	int m;
	cin>>m;
	while(m--){
		int n,x,a,b;
		cin>>n>>x>>a>>b;
		int sum=abs(b-a);
		while(x!=0&&sum!=n-1){
			if(b<=n&&x>0){
				x--;
				sum++;
				b++;
			}
			if(a>0&&x>0){
				x--;
				sum++;
				a--;
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int m;
	cin>>m;
	while(m--){
		int n,x,a,b;
		cin>>n>>x>>a>>b;
		if(a-b==n-1){
			cout<<n-1<<endl;
			continue;
		}
		else if(x-a<=0){
			cout<<b-1<<endl;
			continue;
		}
		else if(x+b>=n){
			cout<<n-a-1<<endl;
			continue;
		}
		else if(x==0){
			cout<<abs(a-b)<<endl;
			continue;
		}
		else if(a-x>0&&b+x<=n){
			cout<<abs(a-b)+x<<endl;
			continue;
		}
	}
}


#include <string.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstdlib> //for abs function
#define ll long long
using namespace std;

int main () {
    int t;
    cin>>t;
    for(int i = 0;i<t;i++){
        int n,x,a,b;
        cin>>n>>x>>a>>b;
        if((abs(b-a)+x)>=n)
            cout<<n-1<<endl;
        else
            cout<<abs(b-a)+x<<endl;

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    for(int i = 0;i<t;i++){
        int n,x,a,b;
        cin >>n>>x>>a>>b;
        int max = n-1;
        if(max<=(b-a+x))
            cout<< max;
        else
            cout<< (b-a+x);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    for(int i = 0;i<t;i++){
        int n,x,a,b;
        cin >>n>>x>>a>>b;
        int max = n-1;
        if(max<=(b-a+x))
            cout<< max;
        else
            cout<< (b-a+x);
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std
void main()
{
    int t;
    cin>>t;
    for(int i = 0;i<t;i++){
        int n,x,a,b;
        cin >>n>>x>>a>>b;
        int max = n-1;
        if(max<=(b-a+x))
            cout<< max;
        else
            cout<< (b-a+x);
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
void main()
{
    int t;
    cin>>t;
    for(int i = 0;i<t;i++){
        int n,x,a,b;
        cin >>n>>x>>a>>b;
        int max = n-1;
        if(max<=(b-a+x))
            cout<< max;
        else
            cout<< (b-a+x);
        }
    }
}


#include <stdio.h>
void main()
{
    int t;
    cin>>t;
    for(int i = 0;i<t;i++){
        int n,x,a,b;
        cin >>n>>x>>a>>b;
        int max = n-1;
        if(max<=(b-a+x))
            cout<< max;
        else
            cout<< (b-a+x);
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t, n,x,a,b,c,d;;
    cin>>t;
    while(t--)
    {
       cin>>n>>x>>a>>b;
    c=min(a,b);
    d=max(a,b);
    if(x==0)
    {
        cout<<abs(a-b)<<endl;
    }
    else if(x <=(c-1))
    {
        cout<<abs((c-x)-d)<<endl;
    }
    else if((n-d)>=x)
    {
        cout<<abs((d+x)-c)<<endl;
    }
    else
    {
        cout<<abs(a-b)<<endl;
    }

    }

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t, n,x,a,b,c,d;;
    cin>>t;
    while(t--)
    {
       cin>>n>>x>>a>>b;
    c=min(a,b);
    d=max(a,b);

    if((a==n || a==1)&& (b==n || b==1))
    {
        cout<<abs(a-b)<<endl;
    }
    else if(x==0)
    {
        cout<<abs(a-b)<<endl;
    }
    else if(x <=(c-1))
    {
        cout<<abs((c-x)-d)<<endl;
    }
    else
    {
        cout<<abs((d+x)-c)<<endl;
    }
    }

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t, n,x,a,b,c,d;;
    cin>>t;
    while(t--)
    {
       cin>>n>>x>>a>>b;
    c=min(a,b);
    d=max(a,b);

    if ((c-1)<x || (n-d)<x)
    {
        cout<<abs(a-b)<<endl;
    }
    else if(x==0)
    {
        cout<<abs(a-b)<<endl;
    }
    else if(x <=(c-1))
    {
        cout<<abs((c-x)-d)<<endl;
    }
    else
    {
        cout<<abs((d+x)-c)<<endl;
    }
    }

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t, n,x,a,b,c,d;;
    cin>>t;
    while(t--)
    {
       cin>>n>>x>>a>>b;
    c=min(a,b);
    d=max(a,b);
    if(n==d && c==1)
    {
      cout<<(d-c)<<endl;
    }
    else if(x==0)
    {
        cout<<(d-c)<<endl;
    }
    else if(x <=(c-1))
    {
        cout<<(d-(c-x))<<endl;
    }
    else if((n-d)>=x)
    {
        cout<<(d+x-c)<<endl;
    }
    else
    {
        cout<<d-c<<endl;
    }

    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,i,j,ct=0;
    ll t;
    cin>>t;
    while(t--)
    {
        ll x,a,b;
        cin>>n>>x>>a>>b;

        ll m1=min(a,b);
        ll m2=max(a,b);
        if(x==0)
        {
            cout<<m2-m1<<endl;
            continue;
        }
        ll d1=m1-1;
        if(d1==0)
        {
            m1=1;
        }
        else if(d1>0)
        {
            ll t1=m1;
            m1=m1-min(x,d1);
            x-=min(x,d1);
        }

        ll d2=(n-m2);
        m2=m2+min(d2,x);
        cout<<m2-m1<<endl;

    }

}


 #include<bits/stdc++.h>
using namespace std;
int main()
{
    int t, n,x,a,b,c,d;;
    cin>>t;
    while(t--)
    {
       cin>>n>>x>>a>>b;
    c=min(a,b);
    d=max(a,b);

    if((a==n || a==1)|| (b==n || b==1))
    {
        cout<<abs(a-b)<<endl;
    }
    else if(x==0)
    {
        cout<<abs(a-b)<<endl;
    }
    else if(x <=(c-1))
    {
        cout<<abs((c-x)-d)<<endl;
    }
    else
    {
        cout<<abs((d+x)-c)<<endl;
    }
    }

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t, n,x,a,b,c,d;;
    cin>>t;
    while(t--)
    {
       cin>>n>>x>>a>>b;
    c=min(a,b);
    d=max(a,b);
    if(n==d && c==1)
    {
      cout<<abs(a-b)<<endl;
    }
    else if(x==0)
    {
        cout<<abs(a-b)<<endl;
    }
    else if(x <=(c-1))
    {
        cout<<abs((c-x)-d)<<endl;
    }
    else if((n-d)>=x)
    {
        cout<<abs((d+x)-c)<<endl;
    }
    else
    {
        cout<<abs(a-b)<<endl;
    }

    }

}


#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n,a,b,s,N;

    cin >> N;

    for(int i = 0; i < N; i++)
    {
        cin >> n >> s >> a >> b;
        int temp = 0, ans = 0, p = 0,ans1 = 0, ans2 = 0;
        if(a > b)
        {
            temp = a;
            a = b;
            b = temp;
        }
        if(b + s > n)
        {
            p = n - b;
            ans = b + p;
            if(a - (s - p) < 0)
            {
               ans1 = a - 1;
               ans2 = (ans - 1) + ans1;
            }
            else
            {
                ans1 = a - (s - p);
                ans2 = ans + ans1;
            }
        }
        else
        {
            ans = b + s;
            ans2 = ans - a;
        }

        cout << ans2 << endl;
    }
}


#include<bits/stdc++.h>
#define in freopen("in.txt","r",stdin);

using namespace std;

int main(){

    #ifndef ONLINE_JUDGE
    in
    #endif // ONLINE_JUDGE

    int test;

    cin >> test;

    while( test-- ){

        int n,s,a,b;

        cin >> n >> s >> a >> b;

        cout << min((abs(a-b)+s),(n-1)) << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define in freopen("in.txt","r",stdin);

using namespace std;

int main(){

    #ifndef ONLINE_JUDGE
    in
    #endif // ONLINE_JUDGE

    int test;

    cin >> test;

    while( test-- ){

        int n,s,a,b;

        cin >> n >> s >> a >> b;

        int x = (a + s);
        int x_= (a - s);

        if(x > n) x = n;
        if(x_ < 0) x_ = 0;

        int y = (b + s);
        int y_= (b - s);

        if(y > n) y = n;
        if(y_ < 0) y_ = 0;

        int mxa,mxb;

        if(abs(x - b) || abs(x_ - b)){
            int m = abs(x - b);
            int n = abs(x_ - b);
            mxa = max(m,n);
        }
        if(abs(y - a) || abs(y_ - a)){
            int m = abs(y - a);
            int n = abs(y_ - a);
            mxb = max(m,n);
        }

        cout << max(mxa,mxb) - abs(mxa - mxb) << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define in freopen("in.txt","r",stdin);

using namespace std;

int main(){

    #ifndef ONLINE_JUDGE
    in
    #endif // ONLINE_JUDGE

    int test;

    cin >> test;

    while( test-- ){

        int n,s,a,b;

        cin >> n >> s >> a >> b;

        int x = (a + s);
        int x_= (a - s);

        if(x > n) x = n;
        if(x_ < 0) x_ = 0;

        int y = (b + s);
        int y_= (b - s);

        if(y > n) y = n;
        if(y_ < 0) y_ = 0;

        int mxa,mxb;

        if(abs(x - b) || abs(x_ - b)){
            int m = abs(x - b);
            int n = abs(x_ - b);
            mxa = max(m,n);
        }
        if(abs(y - a) || abs(y_ - a)){
            int m = abs(y - a);
            int n = abs(y_ - a);
            mxb = max(m,n);
        }

        cout << min(mxa,mxb) << endl;
    }
    return 0;
}


#include<iostream>
#include<bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
using namespace std;
int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll n,x,a,b;
		cin>>n>>x>>a>>b;
		ll p = min(a,b);
		ll q = max(a,b);
		while(x>0)
		{
			if(p>1&&x>0)
			{
				p--;
				x--;
			}
			else
				break;
		}
		while(x>0)
		{

			if(q<n&&x>0)
			{
				q++;
				x--;
			}
			else
				break;
		}

		cout<<abs(p-q)<<endl;

	}

}


#include<iostream>
#include<bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
using namespace std;
int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll n,x,a,b;
		cin>>n>>x>>a>>b;
		if(abs(a-b)+x<=n)
		{
			cout<<abs(a-b)+x<<endl;
		}
		else
		{
			cout<<n-min(a,b)<<endl;
		}
	}

}


#include<iostream>
#include<bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
using namespace std;
int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll n,x,a,b;
		cin>>n>>x>>a>>b;
		if(abs(a-b)+x<n)
		{
			cout<<abs(a-b)+x<<endl;
		}
		else
		{
			cout<<n-min(a,b)<<endl;
		}
	}

}


#include<iostream>
#include<bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
using namespace std;
int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll n,x,a,b;
		cin>>n>>x>>a>>b;
		ll p = min(a,b);
		ll q = max(a,b);
		while(x>0)
		{
			if(p>1&&x!=0)
			{
				p--;
				x--;
			}
			if(q<n&&x!=0)
			{
				q++;
				x--;
			}
			else
				break;

		}
		cout<<abs(p-q)<<endl;

	}

}


#include<iostream>
#include<bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
using namespace std;
int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll n,x,a,b;
		cin>>n>>x>>a>>b;
		ll p = min(a,b);
		ll q = max(a,b);
		while(x>0)
		{
			if(p>1&&x>0)
			{
				p--;
				x--;
			}
			if(q<n&&x>0)
			{
				q++;
				x--;
			}
			else
				break;

		}
		cout<<abs(p-q)<<endl;

	}

}


#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int T;
int n,m,a,b;
int main()
{
    scanf("%d",&T);
    while(T--)
    {
      scanf("%d%d%d%d",&n,&m,&a,&b);
      if(a>b)swap(a,b);
      int t=min(a-1,m);
      a-=t;m-=t;
      t=min(n-b,m);
      b+=t;m-=t;
      printf("%d\n",b-a);
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int m,n,x,l,r;

int main(){
	scanf("%d",&n);
	while(n--){
		scanf("%d%d%d%d",&m,&x,&l,&r);
		if(l > r) swap(l,r);
		if(m == 2) { printf("1\n");continue; }
		if(m == 3){
			if(l == 1)
				if(r == 2) if(x % 2 == 1) printf("2\n");
					else printf("1\n");
				else if(x % 2 == 1) printf("1\n");
					else printf("2\n");
			if(l == 2 && r == 3)
				if(x % 2 == 1) printf("2\n");
				else printf("1\n");
			continue;
		}
		if(m - r + l - 1 > x) printf("%d\n",r - l + x);
		else printf("%d\n",m - 1);
	}
	return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
int m;
int n,x,a,b,l,r;

int main(){
	scanf("%d",&m);
	while(m--){
		scanf("%d%d%d%d",&n,&x,&a,&b);
		if(a > b) swap(a,b);
		l = a - 1; r = n - b;
		if(x <= l + r) printf("%d\n",b - a + x);
		else if((x - l - r) % 2 == 0) printf("%d\n",n);
		else printf("%d\n",n - 1);
	}
	return 0;
}


#include <cstdio>
#include <bitset>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <iostream>
#include <cstring>
#include <ctime>

using namespace std;

#define TASKNAME "code"

int n;
int a[1111111];
int bit[1111111];
int read(){
    scanf("%d",&n);
    for (int i=0;i<n;i++) scanf("%d",a+i);
    for (int i=1;i<=n;i++) {
        bit[i]=bit[i+1];
        bit[i]^=(i%n);
    }
    int kq=0;
    for (int i=0;i<n;i++){
        int q;
        q=a[i]^bit[i+1];
        kq^=q;
    }
    printf("%d\n", kq);
}
int process(){
}
int main(){
    #ifndef ONLINE_JUDGE
    freopen(TASKNAME".inp","r",stdin);
    freopen(TASKNAME".out","w",stdout);
    #endif // ONLINE_JUDGE
    read();
    process();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    vector <int> V;
    cin>>n;
    for(int i = 0; i < n; i++) {
	int tmp;
	cin>>tmp;
	V.push_back(tmp);
    }
    int res = 0;
    for(int i = 0; i < n; i++) {
	bool ok = V[i] xor (i%1);
	for(int j = 2; j <= n; j++) {
	    ok = ok xor (i%j);
	}
	res += ok;
    }
    cout<<res<<endl;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
    int n = 0;
    vector <int> V;
    cin>>n;
    for(int i = 0; i < n; i++) {
	int tmp;
	cin>>tmp;
	V.push_back(tmp);
    }
    int res;
    for(int i = 1; i <= n; i++) {
	int ok = V[i-1];
	for(int j = 1; j <= n; j++) {
	    ok ^= (i%j);
	}
	if(i == 1) res = ok;
	else res ^= ok;
    }
    cout<<res<<endl;

}


#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin>>n;
    vector <int> Q(n+1);
    vector <int> P(n);
    int res = 0;
    for(int i = 0; i < n; i++)
	cin>>P[i];
    for(int i = 0; i < n; i++)
	    res ^= P[i];

    for(int i = 1; i <= n; i++) {
	    Q[i] = Q[i-1]^i;
    }
    for(int i = 2; i <= n; i++) {
	    int temp = n/i;
	    if(temp%2) res ^= Q[i-1];
	    res ^= Q[n%i];
    }
    cout<<res<<endl;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin>>n;
    vector <int> Q(n);
    vector <int> P(n);
    int res;
    for(int i = 0; i < n; i++)
	cin>>P[i];

    for(int i = 0; i < n; i++) {
	Q[i] = P[i];
	for(int j = 1; j <= n; j++) {
	    Q[i] ^= (i+1)%j;
	}
	if(i == 0)
	    res = Q[i];
	else
	    res ^= Q[i];
    }
    cout<<res<<endl;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin>>n;
    vector <int> Q(n+1);
    vector <int> P(n);
    int res = 0;
    for(int i = 0; i < n; i++)
	cin>>P[i];
    for(int i = 0; i < n; i++)
	    res ^= P[i];

    for(int i = 1; i <= n; i++) {
	    Q[i] = Q[i-1]^i;
    }
    for(int i = 2; i <= n; i++) {
	    int temp = n/i;
	    if(temp%2) res ^= Q[i-1];
	    res ^= Q[n%i];
    }
    cout<<res<<endl;
}


/*
ID: asif
LANG: C++
TASK: test
*/
//# pragma comment(linker, "/STACK:102400000,102400000")
# include<iostream>
# include<cstdio>
# include<cstdlib>
# include<cstring>
# include<algorithm>
# include<cctype>
# include<cmath>
# include<string>
# include<set>
# include<map>
# include<stack>
# include<queue>
# include<vector>
# include<numeric>
using namespace std;
const int maxn=100005;
const double inf=0.000001;
const int INF=~0U>>1;
const int mod=1000000007;
# define PI (acos(0)*2.0)
# define lson l,m,rt<<1
# define rson m+1,r,rt<<1 | 1
# define PS printf("\n")
# define S(n) scanf("%u",&n)
# define P(n) printf("%u\n",n)
# define Ps(n) printf(" %u",(n))
# define SB(n) scanf("%lld",&n)
# define PB(n) printf("%lld\n",n)
# define PBs(n) printf(" %lld",n)
# define SD(n) scanf("%lf",&n)
# define PD(n) printf("%.3lf\n",n)
# define Sstr(s) scanf("%s",s)
# define Pstr(s) printf("%s\n",s)
# define S0(a) memset(a,0,sizeof(a))
# define S1(a) memset(a,-1,sizeof(a))
typedef long long ll;
unsigned int n,a[maxn],m,num[maxn];
int equal(double x,double y)
{
    if(x-y>=-inf&&x-y<=inf)
        return 0;
    else if(x-y>inf)
        return 1;
    return -1;
}
int main()
{
    //freopen("input.in", "r", stdin);
    //freopen("output.out", "w", stdout);
    while(~S(n))
    {
        unsigned int ans=0;
        for(int i=0;i<n;i++)
        {
            S(a[i]);
            ans^=a[i];
        }
        S0(num);
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<i;j++)
                num[i]^=i%j;
            if(!((n-i)&1))
                num[i]^=i;
        }
        for(int i=1;i<=n;i++)
            ans^=num[i];
        P(ans);
    }
    return 0;
}


/*
ID: asif
LANG: C++
TASK: test
*/
//# pragma comment(linker, "/STACK:102400000,102400000")
# include<iostream>
# include<cstdio>
# include<cstdlib>
# include<cstring>
# include<algorithm>
# include<cctype>
# include<cmath>
# include<string>
# include<set>
# include<map>
# include<stack>
# include<queue>
# include<vector>
# include<numeric>
using namespace std;
const int maxn=1000005;
const double inf=0.000001;
const int INF=~0U>>1;
const int mod=1000000007;
# define PI (acos(0)*2.0)
# define lson l,m,rt<<1
# define rson m+1,r,rt<<1 | 1
# define PS printf("\n")
# define S(n) scanf("%u",&n)
# define P(n) printf("%u\n",n)
# define Ps(n) printf(" %u",(n))
# define SB(n) scanf("%lld",&n)
# define PB(n) printf("%lld\n",n)
# define PBs(n) printf(" %lld",n)
# define SD(n) scanf("%lf",&n)
# define PD(n) printf("%.3lf\n",n)
# define Sstr(s) scanf("%s",s)
# define Pstr(s) printf("%s\n",s)
# define S0(a) memset(a,0,sizeof(a))
# define S1(a) memset(a,-1,sizeof(a))
typedef long long ll;
unsigned int n,a[maxn],m,num[maxn];
int equal(double x,double y)
{
    if(x-y>=-inf&&x-y<=inf)
        return 0;
    else if(x-y>inf)
        return 1;
    return -1;
}
int main()
{
    //freopen("input.in", "r", stdin);
    //freopen("output.out", "w", stdout);
    while(~S(n))
    {
        unsigned int ans=0;
        for(int i=0;i<n;i++)
        {
            S(a[i]);
            ans^=a[i];
        }
        S0(num);
        for(int i=1;i<=n;i++)
        {
            /*for(int j=1;j<i;j++)
                num[i]^=i%j;*/
            num[i]=(i*(i-1)/2)%i;
            if((n-i)%2)
                num[i]^=i;
        }
        for(int i=1;i<=n;i++)
            ans^=num[i];
        P(ans);
    }
    return 0;
}


/*
ID: asif
LANG: C++
TASK: test
*/
//# pragma comment(linker, "/STACK:102400000,102400000")
# include<iostream>
# include<cstdio>
# include<cstdlib>
# include<cstring>
# include<algorithm>
# include<cctype>
# include<cmath>
# include<string>
# include<set>
# include<map>
# include<stack>
# include<queue>
# include<vector>
# include<numeric>
using namespace std;
const int maxn=1000005;
const double inf=0.000001;
const int INF=~0U>>1;
const int mod=1000000007;
# define PI (acos(0)*2.0)
# define lson l,m,rt<<1
# define rson m+1,r,rt<<1 | 1
# define PS printf("\n")
# define S(n) scanf("%u",&n)
# define P(n) printf("%u\n",n)
# define Ps(n) printf(" %u",(n))
# define SB(n) scanf("%lld",&n)
# define PB(n) printf("%lld\n",n)
# define PBs(n) printf(" %lld",n)
# define SD(n) scanf("%lf",&n)
# define PD(n) printf("%.3lf\n",n)
# define Sstr(s) scanf("%s",s)
# define Pstr(s) printf("%s\n",s)
# define S0(a) memset(a,0,sizeof(a))
# define S1(a) memset(a,-1,sizeof(a))
typedef long long ll;
int n,m;
ll a[maxn],num[maxn];
int equal(double x,double y)
{
    if(x-y>=-inf&&x-y<=inf)
        return 0;
    else if(x-y>inf)
        return 1;
    return -1;
}
void init()
{
    num[0]=0;
    for(int i=1;i<=n;i++)
        num[i]^=num[i-1]^i;
}
int main()
{
    //freopen("input.in", "r", stdin);
    //freopen("output.out", "w", stdout);
    while(~S(n))
    {
        ll ans=0;
        for(int i=0;i<n;i++)
        {
            SB(a[i]);
            ans^=a[i];
        }
        init();
        for(int i=1;i<=n;i++)
        {
            int t1=n/i;
            int t2=n%i;
            if(t1&1)
                ans^=num[i-1];
            if(t2>0)
                ans^=num[t2];
        }
        /*for(int i=1;i<=n;i++)
            ans^=num[i];*/
        P(ans);
    }
    return 0;
}


/*
ID: asif
LANG: C++
TASK: test
*/
//# pragma comment(linker, "/STACK:102400000,102400000")
# include<iostream>
# include<cstdio>
# include<cstdlib>
# include<cstring>
# include<algorithm>
# include<cctype>
# include<cmath>
# include<string>
# include<set>
# include<map>
# include<stack>
# include<queue>
# include<vector>
# include<numeric>
using namespace std;
const int maxn=100005;
const double inf=0.000001;
const int INF=~0U>>1;
const int mod=1000000007;
# define PI (acos(0)*2.0)
# define lson l,m,rt<<1
# define rson m+1,r,rt<<1 | 1
# define PS printf("\n")
# define S(n) scanf("%d",&n)
# define P(n) printf("%d\n",n)
# define Ps(n) printf(" %d",(n))
# define SB(n) scanf("%lld",&n)
# define PB(n) printf("%lld\n",n)
# define PBs(n) printf(" %lld",n)
# define SD(n) scanf("%lf",&n)
# define PD(n) printf("%.3lf\n",n)
# define Sstr(s) scanf("%s",s)
# define Pstr(s) printf("%s\n",s)
# define S0(a) memset(a,0,sizeof(a))
# define S1(a) memset(a,-1,sizeof(a))
typedef long long ll;
int n,a[maxn],m,num[maxn];
int equal(double x,double y)
{
    if(x-y>=-inf&&x-y<=inf)
        return 0;
    else if(x-y>inf)
        return 1;
    return -1;
}
int main()
{
    //freopen("input.in", "r", stdin);
    //freopen("output.out", "w", stdout);
    while(~S(n))
    {
        int ans=0;
        for(int i=0;i<n;i++)
        {
            S(a[i]);
            ans^=a[i];
        }
        S0(num);
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<i;j++)
                num[i]^=i%j;
            if(!((n-i)&1))
                num[i]^=i;
        }
        for(int i=1;i<=n;i++)
            ans^=num[i];
        P(ans);
    }
    return 0;
}


/*
ID: asif
LANG: C++
TASK: test
*/
//# pragma comment(linker, "/STACK:102400000,102400000")
# include<iostream>
# include<cstdio>
# include<cstdlib>
# include<cstring>
# include<algorithm>
# include<cctype>
# include<cmath>
# include<string>
# include<set>
# include<map>
# include<stack>
# include<queue>
# include<vector>
# include<numeric>
using namespace std;
const int maxn=100005;
const double inf=0.000001;
const int INF=~0U>>1;
const int mod=1000000007;
# define PI (acos(0)*2.0)
# define lson l,m,rt<<1
# define rson m+1,r,rt<<1 | 1
# define PS printf("\n")
# define S(n) scanf("%u",&n)
# define P(n) printf("%u\n",n)
# define Ps(n) printf(" %u",(n))
# define SB(n) scanf("%lld",&n)
# define PB(n) printf("%lld\n",n)
# define PBs(n) printf(" %lld",n)
# define SD(n) scanf("%lf",&n)
# define PD(n) printf("%.3lf\n",n)
# define Sstr(s) scanf("%s",s)
# define Pstr(s) printf("%s\n",s)
# define S0(a) memset(a,0,sizeof(a))
# define S1(a) memset(a,-1,sizeof(a))
typedef long long ll;
unsigned int n,a[maxn],m,num[maxn];
int equal(double x,double y)
{
    if(x-y>=-inf&&x-y<=inf)
        return 0;
    else if(x-y>inf)
        return 1;
    return -1;
}
int main()
{
    //freopen("input.in", "r", stdin);
    //freopen("output.out", "w", stdout);
    while(~S(n))
    {
        unsigned int ans=0;
        for(int i=0;i<n;i++)
        {
            S(a[i]);
            ans^=a[i];
        }
        S0(num);
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<i;j++)
                num[i]^=i%j;
            if((n-i)%2)
                num[i]^=i;
        }
        for(int i=1;i<=n;i++)
            ans^=num[i];
        P(ans);
    }
    return 0;
}


/*************************************************************************
Author: zjut_polym
Created Time:   2014/4/25 15:09:20
File Name: codeforces.cpp
************************************************************************/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <climits>
#include <queue>
using namespace std;

//----------------------[ZJUT-polym for div2]-------------------------------------
#define ll long long
#define MOD 1000000007
#define PII pair<int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define _mst(buf, val) memset(buf, val, sizeof(buf))
#define rep(i, l, r) for(i = (l); i <= (r); i++)
#define srep(i, l, r) for(i = (l); i >= (r); i--)
#define repi(it, c) for(typeof(c.begin())it = c.begin(); it != c.end(); it++)
#define inf 0x3f3f3f3f
#define N 1000005
#define eps 1e-8
#define pi (2.0 * acos(0.0))
//--------------------------------------------------------------------------------

int _xor[N];
void init(){
    _xor[0] = 0;
    for(int i = 1; i < N; i++){
        _xor[i] = _xor[i-1] ^ i;
    }
}
int main() {
    int n, ans, val;
    init();
    while(cin >> n){
        ans = 0;
        for(int i = 0; i <  n; i++){
            scanf("%d", &val);
            ans = ans ^ val;
        }
        for(int i = 1; i <= n; i++){
            int len = n / i, p = n % i;
            if(len % 2){
                ans = ans ^ _xor[i-1];
            }
            ans = ans ^ _xor[p];
        }
        cout << ans << endl;
    }
    return 0;
}


/*************************************************************************
Author: zjut_polym
Created Time:   2014/4/25 15:09:20
File Name: codeforces.cpp
************************************************************************/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <climits>
#include <queue>
using namespace std;

//----------------------[ZJUT-polym for div2]-------------------------------------
#define ll long long
#define MOD 1000000007
#define PII pair<int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define _mst(buf, val) memset(buf, val, sizeof(buf))
#define rep(i, l, r) for(i = (l); i <= (r); i++)
#define srep(i, l, r) for(i = (l); i >= (r); i--)
#define repi(it, c) for(typeof(c.begin())it = c.begin(); it != c.end(); it++)
#define inf 0x3f3f3f3f
#define N 1000005
#define eps 1e-8
#define pi (2.0 * acos(0.0))
//--------------------------------------------------------------------------------

int _xor[N];
void init(){
	_xor[0] = 0;
	for(int i = 0; i < N; i++){
		_xor[i] = _xor[i-1] ^ i;
	}
}
int main() {
	int n, ans, val;
	init();
	while(cin >> n){
		ans = 0;
		for(int i = 0; i <  n; i++){
			scanf("%d", &val);
			ans = ans ^ val;
		}
		for(int i = 1; i <= n; i++){
			int len = n / i, p = n % i;
			if(len){
				ans = ans ^ _xor[i];
			}
			ans = ans ^ _xor[p];
		}
		cout << ans << endl;
	}
    return 0;
}


/*************************************************************************
Author: zjut_polym
Created Time:   2014/4/25 15:09:20
File Name: codeforces.cpp
************************************************************************/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <climits>
#include <queue>
using namespace std;

//----------------------[ZJUT-polym for div2]-------------------------------------
#define ll long long
#define MOD 1000000007
#define PII pair<int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define _mst(buf, val) memset(buf, val, sizeof(buf))
#define rep(i, l, r) for(i = (l); i <= (r); i++)
#define srep(i, l, r) for(i = (l); i >= (r); i--)
#define repi(it, c) for(typeof(c.begin())it = c.begin(); it != c.end(); it++)
#define inf 0x3f3f3f3f
#define N 1000005
#define eps 1e-8
#define pi (2.0 * acos(0.0))
//--------------------------------------------------------------------------------

int _xor[N];
void init(){
    _xor[0] = 0;
    for(int i = 1; i < N; i++){
        _xor[i] = _xor[i-1] ^ i;
    }
}
int main() {
    int n, ans, val;
    init();
    while(cin >> n){
        ans = 0;
        for(int i = 0; i <  n; i++){
            scanf("%d", &val);
            ans = ans ^ val;
        }
        for(int i = 1; i <= n; i++){
            int len = n / i, p = n % i;
            if(len){
                ans = ans ^ _xor[i-1];
            }
            ans = ans ^ _xor[p];
        }
        cout << ans << endl;
    }
    return 0;
}


/*************************************************************************
Author: zjut_polym
Created Time:   2014/4/25 15:09:20
File Name: codeforces.cpp
************************************************************************/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <climits>
#include <queue>
using namespace std;

//----------------------[ZJUT-polym for div2]-------------------------------------
#define ll long long
#define MOD 1000000007
#define PII pair<int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define _mst(buf, val) memset(buf, val, sizeof(buf))
#define rep(i, l, r) for(i = (l); i <= (r); i++)
#define srep(i, l, r) for(i = (l); i >= (r); i--)
#define repi(it, c) for(typeof(c.begin())it = c.begin(); it != c.end(); it++)
#define inf 0x3f3f3f3f
#define N 1000005
#define eps 1e-8
#define pi (2.0 * acos(0.0))
//--------------------------------------------------------------------------------

int _xor[N];
void init(){
    _xor[0] = 0;
    for(int i = 1; i < N; i++){
        _xor[i] = _xor[i-1] ^ i;
    }
}
int main() {
    int n, ans, val;
    init();
    while(cin >> n){
        ans = 0;
        for(int i = 0; i <  n; i++){
            scanf("%d", &val);
            ans = ans ^ val;
        }
        for(int i = 1; i <= n; i++){
            int len = n / i, p = n % i;
            if(len){
                ans = ans ^ _xor[i-1];
            }
            if(p){
                int st = i, ed = p + i - 1;
                if(p + i >= n){
                    val = _xor[n-1] ^ _xor[st-1] ^ _xor[ed%n];
                }
                else{
                    val = _xor[ed%n] ^ _xor[st - 1];
                }
                ans = ans ^ val;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


/*************************************************************************
Author: zjut_polym
Created Time:   2014/4/25 15:09:20
File Name: codeforces.cpp
************************************************************************/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <climits>
#include <queue>
using namespace std;

//----------------------[ZJUT-polym for div2]-------------------------------------
#define ll long long
#define MOD 1000000007
#define PII pair<int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define _mst(buf, val) memset(buf, val, sizeof(buf))
#define rep(i, l, r) for(i = (l); i <= (r); i++)
#define srep(i, l, r) for(i = (l); i >= (r); i--)
#define repi(it, c) for(typeof(c.begin())it = c.begin(); it != c.end(); it++)
#define inf 0x3f3f3f3f
#define N 1000005
#define eps 1e-8
#define pi (2.0 * acos(0.0))
//--------------------------------------------------------------------------------

int _xor[N];
void init(){
    _xor[0] = 0;
    for(int i = 1; i < N; i++){
        _xor[i] = _xor[i-1] ^ i;
    }
}
int main() {
    int n, ans, val;
    init();
    while(cin >> n){
        ans = 0;
        for(int i = 0; i <  n; i++){
            scanf("%d", &val);
            ans = ans ^ val;
        }
        for(int i = 1; i <= n; i++){
            int len = n / i, p = n % i;
            if(len){
                ans = ans ^ _xor[i-1];
            }
            if(p){
                int st = i, ed = p + i - 1;
                if(p + i >= n){
                    val = _xor[n-1] ^ _xor[st-1] ^ _xor[ed];
                }
                else{
                    val = _xor[ed] ^ _xor[st - 1];
                }
                ans = ans ^ val;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


/*************************************************************************
Author: zjut_polym
Created Time:   2014/4/25 15:09:20
File Name: codeforces.cpp
************************************************************************/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <climits>
#include <queue>
using namespace std;

//----------------------[ZJUT-polym for div2]-------------------------------------
#define ll long long
#define MOD 1000000007
#define PII pair<int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define _mst(buf, val) memset(buf, val, sizeof(buf))
#define rep(i, l, r) for(i = (l); i <= (r); i++)
#define srep(i, l, r) for(i = (l); i >= (r); i--)
#define repi(it, c) for(typeof(c.begin())it = c.begin(); it != c.end(); it++)
#define inf 0x3f3f3f3f
#define N 1000005
#define eps 1e-8
#define pi (2.0 * acos(0.0))
//--------------------------------------------------------------------------------

int _xor[N];
void init(){
    _xor[0] = 0;
    for(int i = 1; i < N; i++){
        _xor[i] = _xor[i-1] ^ i;
    }
}
int main() {
    int n, ans, val;
    init();
    while(cin >> n){
        ans = 0;
        for(int i = 0; i <  n; i++){
            scanf("%d", &val);
            ans = ans ^ val;
        }
        for(int i = 1; i <= n; i++){
            int len = n / i, p = n % i;
            if(len){
                ans = ans ^ _xor[i-1];
            }
            if(p){
                int st = i, ed = p + i - 1;
                if(ed >= n){
                    val = _xor[n-1] ^ _xor[st-1] ^ _xor[ed%n];
                }
                else{
                    val = _xor[ed%n] ^ _xor[st - 1];
                }
                ans = ans ^ val;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int arr[1000006];

void pre(){
 int i=0;
 for(i=1;i<1000006;i++)
   arr[i] = arr[i-1]^i;
}

int main(){
 int n,answer=0,i,no;
 cin>>n;
 //pre();
 for(i=0;i<n;i++){
   cin>>no;
   answer ^= no;
   if(i!=0)
    arr[i] = arr[i-1]^i;
  }
  arr[n] = arr[n-1] ^ n;
 cout<<answer<<" ";
  for(i=2;i<=n;i++){
    if((n/i)%2){
    cout<<"i "<<i<<" "<<arr[i-1]<<endl;
     answer ^= arr[i-1];
     }
     cout<<"nmodi"<<arr[n%i]<<endl;
    answer ^=  arr[ n%i ];
  }
  cout<<answer;
  return 0;
 }


#include <bits/stdc++.h>

using namespace std;

int arr[1000006];

void pre(){
 int i=0;
 for(i=1;i<1000006;i++)
   arr[i] = arr[i-1]^i;
}

int main(){
 int n,answer=0,i,no;
 cin>>n;
 //pre();
 for(i=0;i<n;i++){
   scanf("%d",&no);//cin>>no;
   answer ^= no;
   if(i!=0)
    arr[i] = arr[i-1]^i;
  }
  arr[n] = arr[n-1] ^ n;
 //cout<<answer<<" ";
  for(i=2;i<=n;i++){
    if((n/i)%2){
   // cout<<"i "<<i<<" "<<arr[i-1]<<endl;
     answer ^= arr[i-1];
     }
     //cout<<"nmodi"<<arr[n%i]<<endl;
    answer ^=  arr[ n%i ];
  }
 printf("%d",answer);// cout<<answer;
  return 0;
 }


#include <bits/stdc++.h>

using namespace std;

int arr[1000006];

void pre(){
 int i=0;
 for(i=1;i<1000006;i++)
   arr[i] = arr[i-1]^i;
}

int main(){
 int n,answer=0,i,no;
 cin>>n;
 pre();
 for(i=0;i<n;i++){
   cin>>no;
   answer ^= no;
  }
// cout<<answer<<" ";
  for(i=2;i<=n;i++){
    if((n/i)%2){
    //cout<<"i "<<i<<" "<<arr[i-1]<<endl;
     answer ^= arr[i-1];
     }
    // cout<<"n\%i"<<arr[n%i]<<endl;
    answer ^=  arr[ n%i ];
  }
  cout<<answer;
  return 0;
 }


#include <bits/stdc++.h>

using namespace std;

int arr[1000006];

void pre(){
 int i=0;
 for(i=1;i<1000006;i++)
   arr[i] = arr[i-1]^i;
}

int main(){
 int n,answer=0,i,no;
 cin>>n;
 //pre();
 for(i=0;i<n;i++){
   cin>>no;
   answer ^= no;
   if(i!=0)
    arr[i] = arr[i-1]^i;
  }
  arr[n] = arr[n-1] ^ n;
 //cout<<answer<<" ";
  for(i=2;i<=n;i++){
    if((n/i)%2){
   // cout<<"i "<<i<<" "<<arr[i-1]<<endl;
     answer ^= arr[i-1];
     }
     //cout<<"nmodi"<<arr[n%i]<<endl;
    answer ^=  arr[ n%i ];
  }
  cout<<answer;
  return 0;
 }


#include <bits/stdc++.h>

using namespace std;

int arr[1000006];

void pre(){
 int i=0;
 for(i=1;i<1000006;i++)
   arr[i] = arr[i-1]^i;
}

int main(){
 int n,answer=0,i,no;
 cin>>n;
 //pre();
 for(i=0;i<n;i++){
   cin>>no;
   answer ^= no;
   if(i!=0)
    arr[i] = arr[i-1]^i;
  }
  arr[n] = arr[n-1] ^ n;
// cout<<answer<<" ";
  for(i=2;i<=n;i++){
    if((n/i)%1){
    //cout<<"i "<<i<<" "<<arr[i-1]<<endl;
     answer ^= arr[i-1];
     }
    // cout<<"n\%i"<<arr[n%i]<<endl;
    answer ^=  arr[ n%i ];
  }
  cout<<answer;
  return 0;
 }


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstring>
#include <queue>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REV(i,a,b) for(int i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define oo 1e9
#define eps 1e-9
#define PI 3.14159265358979323846264338327950
#define MAX 2001
#define sz(v) (int)v.size()
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define show(x) cerr<<#x<<" = "<<x<<endl;
#define mem(s,v) memset(s,v,sizeof(s))
#define ppc(x) __builtin_popcount((x))
#define iter(it,s) for (__typeof(s.begin()) it = s.begin(); it != s.end(); it++)

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

int dx[] = { 0, 0, 1, -1 };
int dy[] = { 1, -1, 0, 0 };

int main() {
#ifndef ONLINE_JUDGE
	freopen("test.in", "rt", stdin);
	//	freopen("o.txt", "wt", stdout);
#endif
	int n, x, xOr[1000001] = { 0 };
	cin >> n;
	vi v(n+1 , 0);
	x = v[0];
	FOR(i , 1 , n+1)
	{
		x ^= v[i];
		xOr[i] = i ^ xOr[i - 1];
	}
	FOR(i , 1 , n + 1)
	{
		if ((n / i) & 1)
			x ^= xOr[i - 1];
		x ^= xOr[n % i];
	}

	cout << x << endl;
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstring>
#include <queue>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REV(i,a,b) for(int i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define oo 1e9
#define eps 1e-9
#define PI 3.14159265358979323846264338327950
#define MAX 2001
#define sz(v) (int)v.size()
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define show(x) cerr<<#x<<" = "<<x<<endl;
#define mem(s,v) memset(s,v,sizeof(s))
#define ppc(x) __builtin_popcount((x))
#define iter(it,s) for (__typeof(s.begin()) it = s.begin(); it != s.end(); it++)

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

int dx[] = { 0, 0, 1, -1 };
int dy[] = { 1, -1, 0, 0 };
int xOr[1000000];
int main() {
#ifndef ONLINE_JUDGE
	freopen("test.in", "rt", stdin);
	//	freopen("o.txt", "wt", stdout);
#endif
	ios::sync_with_stdio(false);
	int n, x;
	scanf("%d" , &n);
	cin >> n;
	vi v(n+1 , 0);
	x = v[0];
	FOR(i , 1 , n+1)
	{
		cin >> v[i];
		x ^= v[i];
		xOr[i] = i ^ xOr[i - 1];
	}
	FOR(i , 1 , n + 1)
	{
		if ((n / i) & 1)
			x ^= xOr[i - 1];
		x ^= xOr[n % i];
	}
	cout << x << endl;
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstring>
#include <queue>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REV(i,a,b) for(int i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define oo 1e9
#define eps 1e-9
#define PI 3.14159265358979323846264338327950
#define MAX 2001
#define sz(v) (int)v.size()
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define show(x) cerr<<#x<<" = "<<x<<endl;
#define mem(s,v) memset(s,v,sizeof(s))
#define ppc(x) __builtin_popcount((x))
#define iter(it,s) for (__typeof(s.begin()) it = s.begin(); it != s.end(); it++)

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

int dx[] = { 0, 0, 1, -1 };
int dy[] = { 1, -1, 0, 0 };
int xOr[1000000];
int main() {
#ifndef ONLINE_JUDGE
	freopen("test.in", "rt", stdin);
	//	freopen("o.txt", "wt", stdout);
#endif
	int n, x;
	scanf("%d" , &n);
//	cin >> n;
	vi v(n+1 , 0);
	x = v[0];
	FOR(i , 1 , n+1)
	{
		scanf("%d" , &v[i]);
		x ^= v[i];
		xOr[i] = i ^ xOr[i - 1];
	}
	FOR(i , 1 , n + 1)
	{
		if ((n / i) & 1)
			x ^= xOr[i - 1];
		x ^= xOr[n % i];
	}
	cout << x << endl;
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstring>
#include <queue>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REV(i,a,b) for(int i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define oo 1e9
#define eps 1e-9
#define PI 3.14159265358979323846264338327950
#define MAX 2001
#define sz(v) (int)v.size()
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define show(x) cerr<<#x<<" = "<<x<<endl;
#define mem(s,v) memset(s,v,sizeof(s))
#define ppc(x) __builtin_popcount((x))
#define iter(it,s) for (__typeof(s.begin()) it = s.begin(); it != s.end(); it++)

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

int dx[] = { 0, 0, 1, -1 };
int dy[] = { 1, -1, 0, 0 };
int xOr[10000000];
int main() {
#ifndef ONLINE_JUDGE
	freopen("test.in", "rt", stdin);
	//	freopen("o.txt", "wt", stdout);
#endif
	int n, x;
	cin >> n;
	vi v(n+1 , 0);
	x = v[0];
	FOR(i , 1 , n+1)
	{
		cin >> v[i];
		x ^= v[i];
		xOr[i] = i ^ xOr[i - 1];
	}
	FOR(i , 1 , n + 1)
	{
		if ((n / i) & 1)
			x ^= xOr[i - 1];
		x ^= xOr[n % i];
	}

	cout << x << endl;
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstring>
#include <queue>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REV(i,a,b) for(int i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define oo 1e9
#define eps 1e-9
#define PI 3.14159265358979323846264338327950
#define MAX 2001
#define sz(v) (int)v.size()
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define show(x) cerr<<#x<<" = "<<x<<endl;
#define mem(s,v) memset(s,v,sizeof(s))
#define ppc(x) __builtin_popcount((x))
#define iter(it,s) for (__typeof(s.begin()) it = s.begin(); it != s.end(); it++)

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

int dx[] = { 0, 0, 1, -1 };
int dy[] = { 1, -1, 0, 0 };

int main() {
#ifndef ONLINE_JUDGE
	freopen("test.in", "rt", stdin);
	//	freopen("o.txt", "wt", stdout);
#endif
	int n, x, xOr[1000001] = { 0 };
	cin >> n;
	vi v(n+1 , 0);
	x = v[0];
	FOR(i , 1 , n+1)
	{
		cin >> v[i];
		x ^= v[i];
		xOr[i] = i ^ xOr[i - 1];
	}
	FOR(i , 1 , n + 1)
	{
		if ((n / i) & 1)
			x ^= xOr[i - 1];
		x ^= xOr[n % i];
	}

	cout << x << endl;
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstring>
#include <queue>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REV(i,a,b) for(int i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define oo 1e9
#define eps 1e-9
#define PI 3.14159265358979323846264338327950
#define MAX 2001
#define sz(v) (int)v.size()
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define show(x) cerr<<#x<<" = "<<x<<endl;
#define mem(s,v) memset(s,v,sizeof(s))
#define ppc(x) __builtin_popcount((x))
#define iter(it,s) for (__typeof(s.begin()) it = s.begin(); it != s.end(); it++)

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

int dx[] = { 0, 0, 1, -1 };
int dy[] = { 1, -1, 0, 0 };
int xOr[1000000];
int main() {
#ifndef ONLINE_JUDGE
	freopen("test.in", "rt", stdin);
	//	freopen("o.txt", "wt", stdout);
#endif
	ios::sync_with_stdio(false);
	int n, x;
	cin >> n;
	vi v(n+1 , 0);
	x = v[0];
	FOR(i , 1 , n+1)
	{
		cin >> v[i];
		x ^= v[i];
		xOr[i] = i ^ xOr[i - 1];
	}
	FOR(i , 1 , n + 1)
	{
		if ((n / i) & 1)
			x ^= xOr[i - 1];
		x ^= xOr[n % i];
	}
	cout << x << endl;
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstring>
#include <queue>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REV(i,a,b) for(int i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define oo 1e9
#define eps 1e-9
#define PI 3.14159265358979323846264338327950
#define MAX 2001
#define sz(v) (int)v.size()
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define show(x) cerr<<#x<<" = "<<x<<endl;
#define mem(s,v) memset(s,v,sizeof(s))
#define ppc(x) __builtin_popcount((x))
#define iter(it,s) for (__typeof(s.begin()) it = s.begin(); it != s.end(); it++)

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

int dx[] = { 0, 0, 1, -1 };
int dy[] = { 1, -1, 0, 0 };
int xOr[1000000];
int main() {
#ifndef ONLINE_JUDGE
	freopen("test.in", "rt", stdin);
	//	freopen("o.txt", "wt", stdout);
#endif
	int n, x;
	cin >> n;
	vi v(n+1 , 0);
	x = v[0];
	FOR(i , 1 , n+1)
	{
		cin >> v[i];
		x ^= v[i];
		xOr[i] = i ^ xOr[i - 1];
	}
	FOR(i , 1 , n + 1)
	{
		if ((n / i) & 1)
			x ^= xOr[i - 1];
		x ^= xOr[n % i];
	}

	cout << x << endl;
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstring>
#include <queue>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REV(i,a,b) for(int i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define oo 1e9
#define eps 1e-9
#define PI 3.14159265358979323846264338327950
#define MAX 2001
#define sz(v) (int)v.size()
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define show(x) cerr<<#x<<" = "<<x<<endl;
#define mem(s,v) memset(s,v,sizeof(s))
#define ppc(x) __builtin_popcount((x))
#define iter(it,s) for (__typeof(s.begin()) it = s.begin(); it != s.end(); it++)

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

int dx[] = { 0, 0, 1, -1 };
int dy[] = { 1, -1, 0, 0 };

int main() {
#ifndef ONLINE_JUDGE
	freopen("test.in", "rt", stdin);
	//	freopen("o.txt", "wt", stdout);
#endif
	int n, x, xOr[1000001] = { 0 };
	cin >> n;
	vi v(n+1);
	x = v[0];
	FOR(i , 1 , n+1)
	{
		x ^= v[i];
		xOr[i] = i ^ xOr[i - 1];
	}
	FOR(i , 1 , n + 1)
	{
		if ((n / i) & 1)
			x ^= xOr[i - 1];
		x ^= xOr[n % i];
	}

	cout << x << endl;
	return 0;
}


#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

const int N = int(1e6);

int vec[N];
int arr[N];

int main() {

    int n;
    int Q = 0;
    int res = 0;
    int var = 0;
    cin >> n;

    for (int i = 0; i < n; i++) cin >> vec[i];

    for (int i = 0; i < n; i++){
        res = 0;
        for (int j = 1; j <= n; j++){
            res ^= vec[i]%(j);
        }
        arr[i] = res;
    }

    for (int i = 0; i < n; i++) Q^=arr[i];

    cout << Q << endl;
}


#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

const int N = int(1e6);

int vec[N];
int arr[N];

int main() {

    int n;
    int Q = 0;
    int res = 0;
    int var = 0;
    cin >> n;

    for (int i = 0; i < n; i++) cin >> vec[i];

    for (int i = 0; i < n; i++){
        res = 0;
        for (int j = 1; j <= n; j++){
            res ^= vec[i]%(j);
        }
        arr[i] = res;
    }
    Q = arr[0];
    for (int i = 1; i < n; i++) Q^=arr[i];

    cout << Q << endl;
}


#include <cstdio>
#include <iostream>
#define N 1000000

using namespace std;

int v[N];
int ar[N];

int main() {

    int n;
    int Q = 0;
    int res = 0;
    cin >> n;

    for (int i = 0; i < n; i++)
        cin >> v[i];

    for (int i = 1; i <= n; i++){
        res = v[i-1];
        for (int j = 1; j <= n; j++){
            res ^= i%j;
        }
        ar[i-1] = res;
    }

    Q = ar[0];
    for (int i = 1; i < n; i++)
        Q^=ar[i];

    cout << Q << endl;
}


#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

const int N = int(1e6);

int vec[N];

int main() {

    int n;
    int res = 0;
    int var = 0;
    cin >> n;

    for (int i = 0; i < n; i++)
        cin >> vec[i];
    for (int i = 0; i < n; i++){
        for (int j = 1; j <= n; j++){
            res ^= vec[i]%(j);
        }
    }
    cout << res << endl;
}


#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#define N 1000000
using namespace std;

int v[N];
int ar[N];

int main() {

    int n;
    int Q = 0;
    int res = 0;
    cin >> n;

    for (int i = 0; i < n; i++) cin >> v[i];

    for (int i = 0; i < n; i++){
        res = 0;
        for (int j = 1; j <= n; j++){
            res ^= v[i]%(j);
        }
        ar[i] = res;
    }
    Q = ar[0];
    for (int i = 1; i < n; i++) Q^=ar[i];

    cout << Q << endl;
}


#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

const int N = int(1e6);

int vec[N];

int main() {

    int n;
    int res = 0;
    int var = 0;
    cin >> n;

    for (int i = 0; i < n; i++)
        cin >> vec[i];
    for (int i = 0; i < n; i++){
        for (int j = 1; j <= n; j++){
            res += vec[i]%(j);
            var ^=res;
        }
    }
    cout << var << endl;
}


#include <cstdio>
#include <iostream>

using namespace std;

#define LIM 1000010

long vector[LIM];

int main() {

    long i,j,k,n,p,ans;
    vector[0] = 0;
    vector[1] = 0;

    for (int i = 2; i < LIM-5; i++)

        vector[i] = (i-1)^vector[i-1];

    cin >> n;
    cin >> p;

    ans = p;

    for (int i = 1; i< n; i++) {
        cin >> p;
        ans ^=p;
    }

    for (int i = 1; i <= n; i++) {

        long temp = vector[i];

        if ((n/i)%2)  ans ^= temp;

        long rem = n%i;

        if (rem) ans ^= vector[rem+1];

    }

    cout << ans << endl;
}


#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#define N 1000000

using namespace std;

int v[N];
int ar[N];

int main() {

    int n;
    int Q = 0;
    int res = 0;
    cin >> n;

    for (int i = 0; i < n; i++)
        cin >> v[i];

    for (int i = 1; i <= n; i++){
        res = v[i-1];
        for (int j = 1; j <= n; j++){
            res ^= i%j;
        }
        ar[i-1] = res;
    }

    Q = ar[0];
    for (int i = 1; i < n; i++)
        Q^=ar[i];

    cout << Q << endl;
}


#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#define N 2000000000

using namespace std;

int v[N];
int ar[N];

int main() {

    int n;
    int Q = 0;
    int res = 0;
    cin >> n;

    for (int i = 0; i < n; i++)
        cin >> v[i];

    for (int i = 1; i <= n; i++){
        res = v[i-1];
        for (int j = 1; j <= n; j++){
            res ^= i%j;
        }
        ar[i-1] = res;
    }

    Q = ar[0];
    for (int i = 1; i < n; i++)
        Q^=ar[i];

    cout << Q << endl;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
typedef __int64 ll ;
const int M=1000000;
int p[1000003],mmod[1000003];
void init(){
	mmod[0]=0;
	for(int i=1;i<=M;i++)mmod[i]=mmod[i-1]^i;
}
int main()
{
	init();
	int n;
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<=n;i++)scanf("%d",&p[i]);
	for(int i=1;i<=n;i++)ans=ans^p[i];
	for(int i=2;i<=n;i++){
		int tmp=n/i;
		if(tmp%2==0)ans^=mmod[n%i];
		else ans^=mmod[i-1],ans^=mmod[n%i];
	}
	printf("%d\n",ans);
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
typedef __int64 ll ;
ll p[1000003];
int main()
{
	int n;
	scanf("%d",&n);
	ll ans=0;
	for(int i=1;i<=n;i++)scanf("%I64d",&p[i]);
	for(int i=1;i<=n;i++)ans=ans^p[i];
	for(int i=2;i<=n;i++){
		int tmp=n/i;
		if(n%i==0&&tmp%2==0)continue;
		if(tmp%2==0)for(int j=1;j<=tmp;j++)ans^=(j%i);
		else{
			if(n%i==0)for(int j=1;j<=i;j++)ans^=(j%i);
			else for(int j=1;j<=i+n%i;j++)ans^=(j%i);
		}
	}
	printf("%I64d\n",ans);
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
typedef __int64 ll ;
ll p[1000003];
int main()
{
	int n;
	scanf("%d",&n);
	ll ans=0;
	for(int i=1;i<=n;i++)scanf("%I64d",&p[i]);
	for(int i=1;i<=n;i++)ans=ans^p[i];
	for(int i=2;i<=n;i++){
		int tmp=n/i;
		if(n%i==0&&tmp%2==0)continue;
		if(tmp%2==0)for(int j=1;j<=n%i;j++)ans^=(j%i);
		else{
			if(n%i==0)for(int j=1;j<=i;j++)ans^=(j%i);
			else for(int j=1;j<=i+n%i;j++)ans^=(j%i);
		}
	}
	printf("%I64d\n",ans);
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
int p[1000003],q[1000004];
int main()
{
	int n;
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<=n;i++)scanf("%d",&p[i]);
	for(int i=1;i<=n;i++)ans=ans^p[i];
	if(n%2==0)ans^=1;
	for(int i=2;i<=n;i++){
		int tmp=(n-i)/i;
		if((n-i)%i){
			for(int j=1;j<=i+tmp;j++)ans^=(j%n);
		}
	}
	printf("%d\n",ans);
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
typedef __int64 ll ;
const int M=1000000;
ll p[1000003],mmod[1000003];
void init(){
	mmod[0]=0;
	for(int i=1;i<=M;i++)mmod[i]=mmod[i-1]^i;
}
int main()
{
	init();
	int n;
	scanf("%d",&n);
	ll ans=0;
	for(int i=1;i<=n;i++)scanf("%I64d",&p[i]);
	for(int i=1;i<=n;i++)ans=ans^p[i];
	for(int i=2;i<=n;i++){
		int tmp=n/i;
		if(n%i==0&&tmp%2==0)continue;
		if(tmp%2==0)/*for(int j=1;j<=n%i;j++)ans^=(j%i);*/ans^=mmod[n%i];
		else{
			if(n%i==0)/*for(int j=1;j<=i;j++)ans^=(j%i);*/ans^=mmod[i-1];
			else /*for(int j=1;j<=i+n%i;j++)ans^=(j%i);*/ans^=mmod[i-1];ans^=mmod[n%i];
		}
	}
	printf("%I64d\n",ans);
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
int p[1000003],q[1000004];
int main()
{
	int n;
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<=n;i++)scanf("%d",&p[i]);
	for(int i=1;i<=n;i++)ans=ans^p[i];
	for(int i=1;i<=n;i++){
		int tmp=n/i;
		if(n%i){
			for(int j=1;j<=i+tmp;j++)ans^=(j%n);
		}
	}
	printf("%d\n",ans);
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
const int M=1000000;
int p[1000003],mmod[1000003];
void init(){
	mmod[0]=0;
	for(int i=1;i<=M;i++)mmod[i]=mmod[i-1]^i;
}
int main()
{
//	freopen("formulas.in","r",stdin);
//	freopen("formulas.out","w",stdout);
	init();
	int n;
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<=n;i++)scanf("%d",&p[i]);
	for(int i=1;i<=n;i++)ans=ans^p[i];
	for(int i=2;i<=n;i++){
		int tmp=n/i;
		if(tmp%2==0)ans^=mmod[n%i];
		else ans^=mmod[i-1],ans^=mmod[n%i];
	}
	printf("%d\n",ans);
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
typedef __int64 ll ;
const int M=1000000;
int p[1000003],mmod[1000003];
void init(){
	mmod[0]=0;
	for(int i=1;i<=M;i++)mmod[i]=mmod[i-1]^i;
}
int main()
{
	init();
	int n;
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<=n;i++)scanf("%d",&p[i]);
	for(int i=1;i<=n;i++)ans=ans^p[i];
	for(int i=2;i<=n;i++){
		int tmp=n/i;
		if(n%i==0&&tmp%2==0)continue;
		if(tmp%2==0)/*for(int j=1;j<=n%i;j++)ans^=(j%i);*/ans^=mmod[n%i];
		else{
			if(n%i==0)/*for(int j=1;j<=i;j++)ans^=(j%i);*/ans^=mmod[i-1];
			else /*for(int j=1;j<=i+n%i;j++)ans^=(j%i);*/ans^=mmod[i-1];ans^=mmod[n%i];
		}
	}
	printf("%d\n",ans);
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
typedef __int64 ll ;
const int M=1000000;
int p[1000003],mmod[1000003];
void init(){
	mmod[0]=0;
	for(int i=1;i<=M;i++)mmod[i]=mmod[i-1]^i;
}
int main()
{
	init();
	int n;
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<=n;i++)scanf("%d",&p[i]);
	for(int i=1;i<=n;i++)ans=ans^p[i];
	for(int i=2;i<=n;i++){
		int tmp=n/i;
		if(tmp%2==0)ans^=mmod[n%i];
		else ans^=mmod[i-1];ans^=mmod[n%i];
	}
	printf("%d\n",ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define inf 0x3f3f3f3f

#define NN 1000005

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

int p[NN];

int f[NN];

int c[NN];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	//freopen("out.out", "w", stdout);

#endif

	int n,q=0;

	scanf("%d",&n);

	f[0]=0;

	for(int i=1;i<=n;i++){

		f[i]=f[i-1]^i;

	}

	for(int i=1;i<=n;i++){

		scanf("%d",&p[i]);

		int buf=n/i;

		if(buf%2) c[i]=p[i]^f[i-1]^f[n%i];

		else c[i]=p[i]^f[n%i];

	}

	for(int i=1;i<=n;i++) q^=c[i];

	cout<<q;

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define MOD 1000000007

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

void gn(INT &x){

	char c;

	while(c=getchar(),c<'0'||c>'9');

	for(x=0;c>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0',c=getchar());

}

#define NN 1111111

int p[NN],f[NN],q[NN];

int ans;

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int n;

	scanf("%d",&n);

	for(int i=1;i<=n;i++) scanf("%d",&p[i]);

	f[0]=0;

	for(int i=1;i<=n;i++){

		f[i]=f[i-1]^i;

	}

	for(int i=1;i<=n;i++){

		if((n/i)&1){

			q[i]=p[i]^f[i-1]^f[n%i];

		}

		else{

			q[i]=p[i]^f[n%i];

		}

	}

	ans=q[1];

	for(int i=2;i<=n;i++){

		ans^=q[i];

	}

	printf("%d\n",ans);

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

#define inf 0x3f3f3f3f

#define NN 1000005

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

int p[NN];

int f[NN];

int c[NN];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	//freopen("out.out", "w", stdout);

#endif

	int n,q=0;

	cin>>n;

	f[0]=0;

	for(int i=1;i<=n;i++){

		f[i]=f[i-1]^i;

	}

	for(int i=1;i<=n;i++){

		cin>>p[i];

		int buf=n/i;

		if(buf%2) c[i]=p[i]^f[i-1]^f[n%i];

		else c[i]=p[i]^f[n%i];

	}

	for(int i=1;i<=n;i++) q^=c[i];

	cout<<q;

	return 0;

}


#include<bits/stdc++.h>

#define x first

#define y second

#define pb push_back

#define inf 0x3f3f3f3f

#define mod 1000000007

#define sq(x) ((x)*(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef vector<int> VI;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

long long  f[1100000];

long long  c[1100000];

long long  p[1100000];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	f[0]=0;

	int n;

	scanf("%d",&n);

	for(int i=1;i<=n;i++) scanf("%I64d",&p[i]);

	long long q=0;

	for(int i=1;i<=n;i++) f[i]=f[i-1] ^ i;

	for(int i=1;i<=n;i++) {

		if((n/i)%2==1) {

			c[i]=p[i]^f[i-1]^(f[n]%i);

		}

		else {

			c[i]=p[i]^(f[n]%i);

		}

	}

	q=c[1];

	for(int i=1;i<=n;i++){

		q=q^c[i];

	}

	printf("%I64d",q);

}


#include<bits/stdc++.h>

#define x first

#define y second

#define pb push_back

#define inf 0x3f3f3f3f

#define mod 1000000007

#define sq(x) ((x)*(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef vector<int> VI;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

long long  f[1100000];

long long  c[1100000];

long long  p[1100000];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	f[0]=0;

	int n;

	scanf("%d",&n);

	for(int i=1;i<=n;i++) scanf("%d",&p[i]);

	long long q=0;

	for(int i=1;i<=n;i++) f[i]=f[i-1] ^ i;

	for(int i=1;i<=n;i++) {

		if((n/i)%2==1) {

			c[i]=p[i]^f[i-1]^(f[n]%i);

		}

		else {

			c[i]=p[i]^(f[n]%i);

		}

	}

	q=c[1];

	for(int i=1;i<=n;i++){

		q=q^c[i];

	}

	printf("%I64d",q);

}


#include<bits/stdc++.h>

using namespace std;

int a[1000010],b[1000010];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

//	freopen("out.out", "w", stdout);

#endif

	int n;

	cin>>n;

	for(int i=1; i<=n; i++) scanf("%d",&a[i]);

	b[0]=0;

	for(int i=1; i<=n; i++) b[i]=b[i-1]^i;

	int ans=0;

	for(int i=1; i<=n; i++){

		if((n/i)%2==1) ans=ans^a[i]^b[i-1]^b[n%i];

		else ans=ans^a[i]^b[n%i];

	}

	printf("%d\n",ans);

	return 0;

}


#include<bits/stdc++.h>

#define x first

#define y second

#define pb push_back

#define inf 0x3f3f3f3f

#define mod 1000000007

#define sq(x) ((x)*(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef vector<int> VI;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

long long  f[1100000];

long long  c[1100000];

long long  p[1100000];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	f[0]=0;

	int n;

	scanf("%d",&n);

	for(int i=1;i<=n;i++) scanf("%I64d",&p[i]);

	long long q=0;

	for(int i=1;i<=n;i++) f[i]=f[i-1] ^ i;

	for(int i=1;i<=n;i++) {

		if((n/i)%2==1) {

			c[i]=p[i]^f[i-1]^(f[n%i]);

		}

		else {

			c[i]=p[i]^(f[n%i]);

		}

	}

	q=c[1];

	for(int i=2;i<=n;i++){

		q=q^c[i];

	}

	printf("%I64d",q);

}


#include <bits/stdc++.h>

#define NN 1000010

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define MOD 1000000007

#define pb push_back

#define x first

#define y second

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

long long p[NN],f[NN],ans;

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

		int n;

		scanf("%d",&n);

		for(int i=1;i<=n;i++) scanf("%I64d",&p[i]);

//		for(int i=1;i<=n;i++) printf("%I64d\n",p[i]);

		for(int i=1;i<=n;i++) f[i]=f[i-1]^i;

		for(int i=1;i<=n;i++) {

			int q=n%i;

			if((n/i)%2==1) ans^=p[i]^f[i-1]^f[q];

			else ans^=p[i]^f[q];

		}

		printf("%I64d",ans);

		return 0;

}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define  inf  0x5fffffff
#define FOR(i,n) for(long long (i)=1;(i)<=(n);(i)++)
#define out(i) <<#i<<"="<<i<<"  "
#define OUT1(a1) cout out(a1) <<endl
#define OUT2(a1,a2) cout out(a1) out(a2) <<endl
#define OUT3(a1,a2,a3) cout out(a1) out(a2) out(a3)<<endl

using namespace std;
int max(int a,int b) {return a>b?a:b;}
int min(int a,int b) {return a<b?a:b;}
int zdgys(int a,int b){int t;if(a<b) {t=a;a=b;b=t;} while(b){t=a;a=b;b=t%b;}return a;}
int zxgbs(int a,int b){return a/zdgys(a,b)*b;}

int quickxor(int a,int b){
    if(b==0) return 0;
    if(b==1) return a;
    if(b==2) return a^a;
    if(b&1) return a^quickxor(a,b>>1);
    else return quickxor(a,b>>1);
}

int fact(int a,int b){
    if(b==1) return 0;
    int m=0;
    for(int i=1;i<b;i++){
        m^=i;
    }
    int d=a%b;
    int ANS=0;
    for(int i=1;i<=d;i++){
        ANS^=i;
    }

    return ANS^quickxor(m,a/b);

}

int main(void)
{

    int n;
    cin>>n;
    int d=0,e;
    for(int i=0;i<n;i++){
        scanf("%d",&e);
        d^=e;
    }
    for(int i=1;i<=n;i++){
        d^=fact(n,i);
    }
    cout<<d <<endl;

return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define  inf  0x5fffffff
#define FOR(i,n) for(long long (i)=1;(i)<=(n);(i)++)
#define out(i) <<#i<<"="<<(i)<<"  "
#define OUT1(a1) cout out(a1) <<endl
#define OUT2(a1,a2) cout out(a1) out(a2) <<endl
#define OUT3(a1,a2,a3) cout out(a1) out(a2) out(a3)<<endl

using namespace std;
int max(int a,int b) {return a>b?a:b;}
int min(int a,int b) {return a<b?a:b;}
int zdgys(int a,int b){int t;if(a<b) {t=a;a=b;b=t;} while(b){t=a;a=b;b=t%b;}return a;}
int zxgbs(int a,int b){return a/zdgys(a,b)*b;}

int quickxor(int a,int b){
    if(b==0) return 0;
    if(b==1) return a;
    if(b==2) return a^a;
    int t=quickxor(a,b>>1);
    if(b&1) return a^t^t;
    else return t^t;
}
int quickxorTo(int n){
     int a=0;
     if(n==2) return 1;
     if(n==3) return 3;
     for(int i=0;i<32;i++){
        if(n&(1<<i)) a=i;
     }
     int ANS=0;
     //cout<<(1<<a)<<endl;
     for(int i=(1<<a);i<n;i++){

        ANS^=i;
        //OUT2(i,ANS);
     }

     return ANS;
}
int fact(int a,int b){
    if(b==1) return 0;
    int m=0;
    //for(int i=1;i<b;i++){
    //  m^=i;
    //}
    m=quickxorTo(b);
    int d=a%b;
    int ANS=0;
    //for(int i=1;i<=d;i++){
    //  ANS^=i;
    //}
    ANS=quickxorTo(d+1);

    return ANS^quickxor(m,a/b);

}

int main(void)
{

    int n;
    cin>>n;
    int d=0,e;
    for(int i=0;i<n;i++){
        scanf("%d",&e);
        d^=e;
    }
    for(int i=1;i<=n;i++){
        d^=fact(n,i);
    }
    cout<<d <<endl;

return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define  inf  0x5fffffff
#define FOR(i,n) for(long long (i)=1;(i)<=(n);(i)++)
#define out(i) <<#i<<"="<<i<<"  "
#define OUT1(a1) cout out(a1) <<endl
#define OUT2(a1,a2) cout out(a1) out(a2) <<endl
#define OUT3(a1,a2,a3) cout out(a1) out(a2) out(a3)<<endl

using namespace std;
int max(int a,int b) {return a>b?a:b;}
int min(int a,int b) {return a<b?a:b;}
int zdgys(int a,int b){int t;if(a<b) {t=a;a=b;b=t;} while(b){t=a;a=b;b=t%b;}return a;}
int zxgbs(int a,int b){return a/zdgys(a,b)*b;}

int quickxor(int a,int b){
    if(b==0) return 0;
    if(b==1) return a;
    if(b==2) return a^a;
    if(b&1) return a^quickxor(a,b>>1);
    else return quickxor(a,b>>1);
}

int fact(int a,int b){
    if(b==1) return 0;
    int m=0;
    for(int i=1;i<b;i++){
        m^=i;
    }
    int d=a%b;
    int ANS=0;
    for(int i=1;i<=d;i++){
        ANS^=d;
    }

    return ANS^quickxor(m,a/b);

}

int main(void)
{

    int n;
    cin>>n;
    int d=0,e;
    for(int i=0;i<n;i++){
        scanf("%d",&e);
        d^=e;
    }
    for(int i=1;i<=n;i++){
        d^=fact(n,i);
    }
    cout<<d <<endl;

return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define  inf  0x5fffffff
#define FOR(i,n) for(long long (i)=1;(i)<=(n);(i)++)
#define out(i) <<#i<<"="<<i<<"  "
#define OUT1(a1) cout out(a1) <<endl
#define OUT2(a1,a2) cout out(a1) out(a2) <<endl
#define OUT3(a1,a2,a3) cout out(a1) out(a2) out(a3)<<endl

using namespace std;
int max(int a,int b) {return a>b?a:b;}
int min(int a,int b) {return a<b?a:b;}
int zdgys(int a,int b){int t;if(a<b) {t=a;a=b;b=t;} while(b){t=a;a=b;b=t%b;}return a;}
int zxgbs(int a,int b){return a/zdgys(a,b)*b;}

int quickxor(int a,int b){
    if(b==0) return 0;
    if(b==1) return a;
    if(b==2) return a^a;
    if(b&1) return a^quickxor(a,b>>1);
    else return quickxor(a,b>>1);
}

int fact(int a,int b){
    if(b==1) return 0;
    int m=0;
    for(int i=1;i<=b;i++){
        m|=i;
    }
    return quickxor(a,a%b)^quickxor(m,a/b);

}

int main(void)
{

    int n;
    cin>>n;
    int d=0,e;
    for(int i=0;i<n;i++){
        scanf("%d",&e);
        d^=e;
    }
    for(int i=1;i<=n;i++){
        d^=fact(n,i);
    }
    cout<<d <<endl;

return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define  inf  0x5fffffff
#define FOR(i,n) for(long long (i)=1;(i)<=(n);(i)++)
#define out(i) <<#i<<"="<<(i)<<"  "
#define OUT1(a1) cout out(a1) <<endl
#define OUT2(a1,a2) cout out(a1) out(a2) <<endl
#define OUT3(a1,a2,a3) cout out(a1) out(a2) out(a3)<<endl

using namespace std;
int max(int a,int b) {return a>b?a:b;}
int min(int a,int b) {return a<b?a:b;}
int zdgys(int a,int b){int t;if(a<b) {t=a;a=b;b=t;} while(b){t=a;a=b;b=t%b;}return a;}
int zxgbs(int a,int b){return a/zdgys(a,b)*b;}

int quickxor(int a,int b){
    if(b==0) return 0;
    if(b==1) return a;
    if(b==2) return a^a;
    int t=quickxor(a,b>>1);
    if(b&1) return a^t^t;
    else return t^t;
}

int quickxorTo(int n){
     int a=0;
     n--;
     switch(n%4){
        case 0: return n;
        case 1: return 1;
        case 2: return n+1;
        case 3: return 0;
     }

}
int fact(int a,int b){
    if(b==1) return 0;
    int m=0;
    //for(int i=1;i<b;i++){
    //  m^=i;
    //}
    m=quickxorTo(b);
    int d=a%b;
    int ANS=0;
    //for(int i=1;i<=d;i++){
    //  ANS^=i;
    //}
    ANS=quickxorTo(d+1);

    return ANS^quickxor(m,a/b);

}

int main(void)
{
    /*
    OUT1(quickxorTo(20));
    int m=0;
    for(int i=1;i<20;i++){
        m^=i;
    }
    OUT1(m);
    OUT1(16^17^18^19);
    return 0;*/
//  int er=0;
//  for(int i=1;i<30;i++){
//      er^=i;
//      OUT2(er,quickxorTo(i+1));
//  }
//  return 0;

    int n;
    cin>>n;
    int d=0,e;
    for(int i=0;i<n;i++){
        scanf("%d",&e);
        d^=e;
    }
    for(int i=1;i<=n;i++){
        d^=fact(n,i);
    }
    cout<<d <<endl;

return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define  inf  0x5fffffff
#define FOR(i,n) for(long long (i)=1;(i)<=(n);(i)++)
#define out(i) <<#i<<"="<<i<<"  "
#define OUT1(a1) cout out(a1) <<endl
#define OUT2(a1,a2) cout out(a1) out(a2) <<endl
#define OUT3(a1,a2,a3) cout out(a1) out(a2) out(a3)<<endl

using namespace std;
int max(int a,int b) {return a>b?a:b;}
int min(int a,int b) {return a<b?a:b;}
int zdgys(int a,int b){int t;if(a<b) {t=a;a=b;b=t;} while(b){t=a;a=b;b=t%b;}return a;}
int zxgbs(int a,int b){return a/zdgys(a,b)*b;}

int quickxor(int a,int b){
    if(b==0) return 0;
    if(b==1) return a;
    if(b==2) return a^a;
    int t=quickxor(a,b>>1);
    if(b&1) return a^t^t;
    else return t^t;
}

int fact(int a,int b){
    if(b==1) return 0;
    int m=0;
    for(int i=1;i<b;i++){
        m^=i;
    }
    int d=a%b;
    int ANS=0;
    for(int i=1;i<=d;i++){
        ANS^=i;
    }

    return ANS^quickxor(m,a/b);

}

int main(void)
{

    int n;
    cin>>n;
    int d=0,e;
    for(int i=0;i<n;i++){
        scanf("%d",&e);
        d^=e;
    }
    for(int i=1;i<=n;i++){
        d^=fact(n,i);
    }
    cout<<d <<endl;

return 0;
}


#include <cstdio>
using namespace std;
const int maxn=1001000;
int n;
int a[maxn],ans,b[maxn];
int main()
{
    int i,j,x,y;
    scanf("%d",&n);
    for (i=1;i<=n;i++) scanf("%d",&a[i]);
    ans=0;
    for (i=1;i<=n;i++) {ans^=a[i]; b[i]=b[i-1]^i;}
    for (i=2;i<=n;i++)
    {
        x=n/i;
        if (x&1) ans^=b[i-1];
        x=n%i;
        ans^=b[x];
    }
    printf("%d\n",ans);
    return 0;
}


#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int p[1000001];
int main()
{
    int i,j,n,Q;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",p+i);
        for(j=1;j<=i;j++)
            p[i]=p[i]^(i%j);
        if((n-i)%2==1)
        {
            p[i]=p[i]^i;
        }
        if(i==1)
            Q=p[i];
        else
        {
            Q=Q^p[i];
        }
    }
    printf("%d",Q);
}


#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int p[1000001];
int q[1000001];
int main()
{
    int i,j,n,Q;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",p+i);
        q[i]=p[i];
        for(j=1;j<=i;j++)
            q[j]=q[j]^(i%n);
        if(i==1)
            Q=q[i];
        else
        {
            Q=Q^q[i];
        }
    }
    printf("%d",Q);
}


#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int p[1000001];
int q[1000001];
int main()
{
    int i,j,n,Q;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",p+i);
        q[i]=p[i];
        for(j=1;j<=n;j++)
            q[i]=q[i]^(i%j);
        if(i==1)
            Q=q[i];
        else
        {
            Q=Q^q[i];
        }
    }
    printf("%d",Q);
}


#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int p;
int main()
{
    int i,j,n,Q;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&p);
        for(j=1;j<=i;j++)
            p=p^(i%j);
        if((n-i)%2)
            p=p^i;
        if(i==1)
            Q=p;
        else
            Q=Q^p;
    }
    printf("%d",Q);
}


#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int p[1000001];
int q[1000001];
int main()
{
    int i,j,n,Q;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",p+i);
        q[i]=p[i];
        for(j=1;j<=i;j++)
            q[i]=q[i]^(i%j);
        if((n-i)%2==1)
        {
            q[i]=q[i]^i;
        }
        if(i==1)
            Q=q[i];
        else
        {
            Q=Q^q[i];
        }
    }
    printf("%d",Q);
}


#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
#define ll long long
ll  p[1000001];
ll  q[1000001];
int main()
{
    ll i,j,n,Q;
    scanf("%I64d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%I64d",p+i);
        q[i]=p[i];
        for(j=1;j<=i;j++)
            q[j]=q[j]^(i%n);
        if(i==1)
            Q=q[i];
        else
        {
            Q=Q^q[i];
        }
    }
    printf("%I64d",Q);
}


#include <bits/stdc++.h>
#include <omp.h>
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define piii pair<int,pii>
#define pss pair<string,string>
#define pdi pair<double,int>
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define mod 1000000007
//#define seg_size  2*(int)pow(2,(int)(ceil(log2(100000)))) - 1;
using namespace std;
long long int n,m=0;

int main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//cout << fixed;
    //cout << setprecision(6);

	long long int i,j=0,k=0,t,size=0,r,no=0,last,flag=0;
	long long int sum=0,p=0;
	cin>>n;
	vector<long long int> v(n);
	for(i=0;i<n;i++)
		cin>>v[i];

	p=v[0];
	for(i=1;i<n;i++)
		p=p^v[i];

	if(n%2==0)
	{
		for(i=1;i<n;i=i+2)
			p=p^i;
	}
	else
	{
		for(i=2;i<n;i=i+2)
			p=p^i;
	}
	for(i=2;i<=3;i++)
	{
		for(j=i+1;j<=n;j++)
			p=p^(j%i);
	}
	for(i=4;i<n;i++)
	{
		j=n/i-1;
		k=i%4;
		if(j%2!=0)
		{
			k=i-k;
			while(k<i)
			{
				p=p^k;
				k++;
			}
		}
		j=j*i+i;
		while(j<=n)
		{
			p=p^(j%i);
			j++;
		}
	}
	cout<<p<<endl;
	return 0;
}


#include <bits/stdc++.h>
#include <omp.h>
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define piii pair<int,pii>
#define pss pair<string,string>
#define pdi pair<double,int>
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define mod 1000000007
//#define seg_size  2*(int)pow(2,(int)(ceil(log2(100000)))) - 1;
using namespace std;
long long int n,m=0;

int main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//cout << fixed;
    //cout << setprecision(6);

	long long int i,j=0,k=0,t,size=0,r,no=0,last,flag=0;
	long long int sum=0,p=0;
	cin>>n;
	vector<long long int> v(n);
	for(i=0;i<n;i++)
		cin>>v[i];

	p=v[0];
	for(i=1;i<n;i++)
		p=p^v[i];

	if(n%2==0)
	{
		for(i=1;i<n;i=i+2)
			p=p^i;
	}
	else
	{
		for(i=2;i<n;i=i+2)
			p=p^i;
	}
	for(i=2;i<n;i++)
	{
		j=i;
		while(j%4!=0)
		{
			p=p^(j%i);
			j++;
		}
		j=(n/4)*4;
		while(j%4!=0)
		{
			p=p^(j%i);
			j++;
		}
	}
	cout<<p<<endl;
	return 0;
}


#include <bits/stdc++.h>
#include <omp.h>
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define piii pair<int,pii>
#define pss pair<string,string>
#define pdi pair<double,int>
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define mod 1000000007
//#define seg_size  2*(int)pow(2,(int)(ceil(log2(100000)))) - 1;
using namespace std;
long long int n,m=0;

int main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//cout << fixed;
    //cout << setprecision(6);

	int i,j=0,k=0,t,size=0,r,no=0,last,flag=0;
	int sum=0,p=0;
	cin>>n;
	vector<int> v(n);
	for(i=0;i<n;i++)
		cin>>v[i];

	p=v[0];
	for(i=1;i<n;i++)
		p=p^v[i];

	if(n%2==0)
	{
		for(i=1;i<n;i=i+2)
			p=p^i;
	}
	else
	{
		for(i=2;i<n;i=i+2)
			p=p^i;
	}
	for(i=2;i<=3;i++)
	{
		for(j=i+1;j<=n;j++)
			p=p^(j%i);
	}
	for(i=4;i<n;i++)
	{
		j=n/i-1;
		k=i%4;
		if(j%2!=0)
		{
			k=i-k;
			while(k<i)
			{
				p=p^k;
				k++;
			}
		}
		j=j*i+i;
		k=(n-j+1)/4;
		j=j+k*4;
		while(j<=n)
		{
			p=p^(j%i);
			j++;
		}
	}
	cout<<p<<endl;
	return 0;
}


#include <bits/stdc++.h>
#include <omp.h>
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define piii pair<int,pii>
#define pss pair<string,string>
#define pdi pair<double,int>
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define mod 1000000007
//#define seg_size  2*(int)pow(2,(int)(ceil(log2(100000)))) - 1;
using namespace std;
long long int n,m=0;

int main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//cout << fixed;
    //cout << setprecision(6);

	long long int i,j=0,k=0,t,size=0,r,no=0,last,flag=0;
	long long int sum=0,p=0;
	cin>>n;
	vector<int> v(n);
	for(i=0;i<n;i++)
		cin>>v[i];

	p=v[0];
	for(i=1;i<n;i++)
		p=p^v[i];

	for(i=2;i<=n;i++)
	{
		k=n%i;
		k++;
		while(k%i!=0)
		{
			p=p^k;
			k++;
		}
	}
	cout<<p<<endl;
	return 0;
}


#include <bits/stdc++.h>
#include <omp.h>
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define piii pair<int,pii>
#define pss pair<string,string>
#define pdi pair<double,int>
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define mod 1000000007
//#define seg_size  2*(int)pow(2,(int)(ceil(log2(100000)))) - 1;
using namespace std;
long long int n,m=0;

int main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//cout << fixed;
    //cout << setprecision(6);

	int i,j=0,k=0,t,size=0,r,no=0,last,flag=0;
	int sum=0,p=0;
	cin>>n;
	vector<int> v(n);
	for(i=0;i<n;i++)
		cin>>v[i];

	p=v[0];
	for(i=1;i<n;i++)
		p=p^v[i];

	if(n%2==0)
	{
		for(i=1;i<n;i=i+2)
			p=p^i;
	}
	else
	{
		for(i=2;i<n;i=i+2)
			p=p^i;
	}
	for(i=2;i<=3;i++)
	{
		for(j=i+1;j<=n;j++)
			p=p^(j%i);
	}
	for(i=4;i<n;i++)
	{
		j=n/i-1;
		k=i%4;
		if(j%2!=0)
		{
			k=i-k;
			while(k<i)
			{
				p=p^k;
				k++;
			}
		}
		j=j*i+i;
		while(j<=n)
		{
			p=p^(j%i);
			j++;
		}
	}
	cout<<p<<endl;
	return 0;
}


#include<iostream>
using namespace std;

const int oo = 1e6 + 10;
long long n, x, y, z, a[oo], ans;

int main(){
  cin >> n;
  for(int i=1;i<=n;i++)
    cin >> x, ans ^= x, a[i] = i ^ a[i - 1], y = n / i, z = n % i, ans ^= a[z], ans ^= ((y % 2) * a[i - 1]);
  cout << ans;
  return 0;
}


#include<iostream>
using namespace std;

const int oo = 1e6 + 10;
long long n, x, y, z, a[oo], ans;

int main(){
  cin >> n;
  for(int i=1;i<=n;i++){
    cin >> x;
    ans ^= x;
    a[i] = i ^ a[i - 1];
    y = n / i;
    z = n % i;
    ans ^= a[z];
    ans ^= ((y % 2) * a[i - 1]);
  }
  cout << ans;
  return 0;
}


#include<iostream>
using namespace std;

const int oo=1e6+10;
long long n,p[oo],Q,a[oo],QQ;

int main(){
  cin>>n;
  for(int i=1;i<=n;i++)a[i]=(a[i-1]^i);
  for(int i=1;i<=n;i++){
    int x=(n-i)/i,y=(n-i)%i;
    if(x%2)
     Q^=a[i-1]|a[y];
    else
      Q^=a[y];
  }
  for(int i=1;i<=n;i++)
    cin>>p[i],Q^=p[i],QQ^=p[i];
  for(int i=1-(n%2);i<=n;i+=2)Q^=i;
   cout<<Q;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
      QQ^=(i%j);
  //cout<<endl<<QQ;
  // if(QQ==Q)cout<<"Y";
  //else cout<<"N";
  return 0;
}


#include<iostream>
using namespace std;

int main(){
  long long n, x, ans = 0, a[1000100] = {0};
  cin >> n;
  for(int i = 1; i <= n; i++)
    cin >> x, a[i] = i ^ a[i - 1], ans ^= (x ^ a[n % i] ^ (((n / i) % 2) * a[i - 1]);
  cout << ans;
  return 0;
}


#include<iostream>
using namespace std;

const int oo=1e6+10;
int n,p[oo],Q,a[oo];

int main(){
  cin>>n;
  for(int i=1;i<=n;i++)a[i]=(a[i-1]^i);
  for(int i=1;i<=n;i++){
    int x=(n-i)/i,y=(n-i)%i;
    if(x%2)
      cerr<<i<<":"<<(a[i-1]|a[y])<<endl, Q^=a[i-1]|a[y];
    else
      cerr<<i<<":"<<a[y]<<endl, Q^=a[y];
  }
  for(int i=1;i<=n;i++)
    cin>>p[i],Q^=p[i];
  for(int i=1-(n%2);i<=n;i+=2)Q^=i;
  cout<<Q;
  return 0;
}


#include<iostream>
using namespace std;

const int oo=1e6+10;
int n,p[oo],Q,a[oo];

int main(){
  cin>>n;
  for(int i=1;i<=10000;i++)
    for(int j=1;j<=i;j++)
      a[i]^=(i%j);
  for(int i=1;i<=n;i++)
    cin>>p[i],Q^=(p[i]^a[i]);
  cout<<Q;
  return 0;
}


#include<iostream>
using namespace std;

int main(){
  long long n, x, ans = 0, a[1000100] = {0};
  cin >> n;
  for(int i = 1; i <= n; i++)
    cin >> x, a[i] = i ^ a[i - 1], ans ^= (x ^ a[n % i]) ^ (( % 2) * a[i - 1]);
  cout << ans;
  return 0;
}


#include<iostream>
using namespace std;

const int oo=1e6+10;
int n,p[oo],Q,a[oo];

int main(){
  cin>>n;
  for(int i=1;i<=10000;i++)
    for(int j=1;j<=n;j++)
      a[i]^=(i%j);
  for(int i=1;i<=n;i++)
    cin>>p[i],Q^=(p[i]^a[i]);
  cout<<Q;
  return 0;
}


#include<iostream>
using namespace std;

const int oo=1e6+10;
long long n,x,y,z,a[oo],ans;

int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>x, ans^=x;
a[i]=i^a[i-1];
y=n/i; z=n%i;
ans^=a[z];
if(y%2)
ans^=a[i-1];
}
cout<<ans;
return 0;
}


#include<iostream>
using namespace std;

int main(){
  long long n, x, ans = 0, a[1000100] = {0};
  cin >> n;
  for(int i = 1; i <= n; i++)
    cin >> x, a[i] = i ^ a[i - 1], ans ^= (x ^ a[n % i]) ^ (((n / i) % 2) * a[i - 1]);
  cout << ans;
  return 0;
}


#include<iostream>
using namespace std;

const int oo=1e6+10;
long long n,p[oo],Q,a[oo],QQ;

int main(){
  cin>>n;
  for(int i=1;i<=n;i++)a[i]=(a[i-1]^i);
  for(int i=1;i<=n;i++){
    int x=(n-i)/i,y=(n-i)%i;
    if(x%2)
     Q^=a[i]|a[y];
    else
      Q^=a[y];
  }
  for(int i=1;i<=n;i++)
    cin>>p[i],Q^=p[i],QQ^=p[i];
  for(int i=1-(n%2);i<=n;i+=2)Q^=i;
   cout<<Q;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
      QQ^=(i%j);
  //cout<<endl<<QQ;
  // if(QQ==Q)cout<<"Y";
  //else cout<<"N";
  return 0;
}


#include <iostream>
#include <string>
using namespace std;
string s;
int main()
{int n;
    while(cin>>n){
        cin>>s;
        int k=0,t=0;
        for(int i=0;i<n;++i){
            if(s[i]=='X')
                k+=1;
        }t=n/2>k?n/2-k:k-n/2;

        cout<<t<<endl;
        if(t==0) cout<<s<<endl;
        if(n/2>k){
            for(int i=0;i<n;++i){
                if(s[i]=='x'){
                    s[i]='X';
                    --t;
                    if(t==0)
                        break;
                }
            }
            cout<<s<<endl;
        }
        else if(n/2<k)
        {
            for(int i=0;i<n;++i){
                if(s[i]=='X'){
                    s[i]='x';
                    --t;
                    if(t==0)
                        break;
                }
            }
            cout<<s<<endl;
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int q[1000010];
int p[1000010];
int t[1000010];
int s[1000010];
int main()
{
    int a=0;
    for(int i=1;i<=1000000;++i){
        a=a^i;
        t[i]=a;
    }int r=0;
    for(int i=1;i<=1000000;++i){
        r=r^t[i];
        s[i]=r;
    }
    int n;
    while(cin>>n){
        int Q=0;
        for(int i=1;i<=n;++i){
            cin>>p[i];
        }
        if(n==1){cout<<p[1]<<endl;continue ;}
        for(int i=1;i<=n;++i){
            int x,y,z;
            x=n/(i+1);
            y=n%(i+1);
            if(x%2==1) q[i]=0;
            else if(x%2==0) q[i]=t[i];
            q[i]=q[i]^t[y];
        }
        for(int i=1;i<=n;++i){
            Q=Q^q[i];
        }
        Q=Q^s[n];
        for(int i=1;i<=n;++i ){
            Q=Q^p[i];
        }
        cout<<Q<<endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int q[1000010];
int p[1000010];
int t[1000010];
int s[1000010];
int main()
{
    int a=0;
    for(int i=1;i<=1000000;++i){
        a=a^i;
        t[i]=a;
    }int r=0;
    for(int i=1;i<=1000000;++i){
        r=r^t[i];
        s[i]=r;
    }
    int n;
    while(cin>>n){
        int Q=0;
        for(int i=1;i<=n;++i){
            cin>>p[i];
        }
        if(n==1){cout<<p[1]<<endl;continue ;}
        for(int i=1;i<=n;++i){
            int x,y,z;
            x=n/(i+1);
            y=n%(i+1);
            if(x%2==1) q[i]=0;
            else if(x%2==0) q[i]=t[i];
            q[i]=q[i]^t[y];
        }
        for(int i=1;i<=n;++i){
            Q=Q^q[i];
        }
        Q=Q^s[n-1];
        for(int i=1;i<=n;++i ){
            Q=Q^p[i];
        }
        cout<<Q<<endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int q[1000010];
int p[1000010];
int t[1000010];
int s[1000010];
int main()
{
    int a=0;
    for(int i=1;i<=1000000;++i){
        a=a^i;
        t[i]=a;
    }int r=0;
    for(int i=1;i<=1000000;++i){
        r=r^t[i];
        s[i]=r;
    }
    int n;
    while(cin>>n){
        int Q=0;
        for(int i=1;i<=n;++i){
            cin>>p[i];
        }
        if(n==1){cout<<p[1]<<endl;continue ;}
        for(int i=1;i<n;++i){
            int x,y,z;
            x=n/(i+1);
            y=n%(i+1);
            if(x%2==1) q[i]=0;
            else if(x%2==0) q[i]=t[i];
            q[i]=q[i]^t[y];
        }
        for(int i=1;i<n;++i){
            Q=Q^q[i];
        }
        Q=Q^s[n-1];
        for(int i=1;i<n;++i ){
            Q=Q^p[i];
        }
        cout<<Q<<endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int q[1000010];
int p[1000010];
int main()
{
    int n;
    while(cin>>n){
        for(int i=1;i<=n;++i){
            scanf("%d",&p[i]);
        }
        for(int i=1;i<=n;++i){
            int t=p[i];
            for(int j=1;j<=n;++j){
                t=t^(i%j);
            }q[i]=t;
        }
        int Q=0;
        for(int i=1;i<=n;++i){
            Q=Q^q[i];
        }
        cout<<Q<<endl;
        }
    return 0;
}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

#define NN 1000111

int bta[NN], p[NN];

int main() {

	int n,i,j;

	cin>>n;

	INT ans=0;

	for(i=1; i<NN; i++){

		bta[i]=bta[i-1]^i;

	}

	for(i=1; i<=n; i++) {

		scanf("%d", p+i);

		ans^=p[i];

		if((n/i)&1) ans^=bta[i-1];

		ans^=bta[(n%i)];

	}

	cout<<ans<<endl;

	return 0;

}


#include<bits/stdc++.h>

#define NN 1000100

using namespace std;

typedef long long INT;

INT p[NN],ans=0;

int main(){

//	freopen("in.txt","r",stdin);

	int n;

	cin>>n;

	for(int i=1;i<=n;i++) {scanf("%I64d",&p[i]); ans^=p[i];}

	for(int i=1;i<=n;i++){

		int j=n%i;

		int k=n/i%2;

		if(j) ans^=1LL*j*(j+1)/2;

		if(k) ans^=1LL*i*(i+1)/2;

	}

	cout<<ans;

	return 0;

}


#include<bits/stdc++.h>

#define NN 1000100

using namespace std;

typedef long long INT;

INT p[NN],ans=0;

int main(){

	int n;

	cin>>n;

	for(int i=1;i<=n;i++) {scanf("%I64d",&p[i]); ans^=p[i];}

	for(int i=1;i<=n;i++){

		int j=n%i;

		int k=n/i%2;

		if(j) for(int m=1;m<=j;m++) ans^=m;

		if(k) for(int m=1;m<=i-1;m++) ans^=m;

	}

	cout<<ans;

	return 0;

}


#include<bits/stdc++.h>

#define NN 1000100

using namespace std;

typedef long long INT;

INT p[NN],ans=0;

int main(){

//	freopen("in.txt","r",stdin);

	int n;

	cin>>n;

	for(int i=1;i<=n;i++) {scanf("%I64d",&p[i]); ans^=p[i];}

	for(int i=1;i<=n;i++){

		int j=n%i;

		int k=n/i%2;

		if(j) ans^=1LL*j*(j+1)/2;

		if(k) ans^=1LL*i*(i-1)/2;

	}

	cout<<ans;

	return 0;

}


#include<bits/stdc++.h>

#define NN 1000100

using namespace std;

typedef long long INT;

INT p[NN],ans=0,nod[NN];

int main(){

//	freopen("in.txt","r",stdin);

	int n;

	cin>>n;

	nod[0]=0;

	for(int i=1;i<=n;i++) nod[i]=nod[i-1]^i;

	for(int i=1;i<=n;i++) {scanf("%I64d",&p[i]); ans^=p[i];}

	for(int i=1;i<=n;i++){

		int j=n%i;

		int k=n/i%2;

		if(j) ans^=nod[j];

		if(k) ans^=nod[i-1];

	}

	cout<<ans;

	return 0;

}


import java.io.*;
import java.util.*;
import java.util.Queue;
import java.awt.*;
import java.math.*;

public class Main {

    static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st = new StringTokenizer("");

    static String next() throws Exception {

        while (!st.hasMoreTokens()) {
            String s = br.readLine();
            if (s == null) {
                return null;
            }
            st = new StringTokenizer(s);
        }
        return st.nextToken();
    }

    public static void main(String[] asda) throws Exception {

        int N = Integer.parseInt( next() );
        if (N < 4) {
            out.println("NO");
        }   else    {
            out.println("YES");
            solve(N);
        }
        //
        out.flush();
        System.exit(0);
    }
    static void solve(int N)    {
        if ( N == 4 )   {
            four();
            return;
        }
        else if ( N == 5 )  {
            five();
            return;
        }

        if ( N % 2 == 0 ) {
            out.println( "6 - 5 = 1");
            out.println( "1 - 1 = 0");
            for (int x = 7; x <= N; x++)
                out.println( "0 * " + x + " = 0");
            out.println("2 + 0 = 2");
            out.println("2 * 3 = 6");
            out.println("6 * 4 = 24");
        }   else    {
            out.println( "7 - 6 = 1");
            out.println( "1 - 1 = 0");
            for (int x = 8; x <= N; x++)
                out.println( "0 * " + x + " = 0");
            out.println("2 + 0 = 2");
            out.println("3 - 2 = 1");
            out.println("5 + 1 = 6");
            out.println("6 * 4 = 24");
        }
    }
    static void five()  {
        out.println("3 - 2 = 1");
        out.println("5 + 1 = 6");
        out.println("6 * 4 = 24");
        out.println("1 * 24 = 24");
    }
    static void four()  {
        out.println("1 * 2 = 2");
        out.println("2 * 3 = 6");
        out.println("6 * 4 = 24");
    }
}


import java.util.Scanner;
public class a {
  static Scanner in=new Scanner(System.in);
  public static void main(String[] args) {
    int n=in.nextInt();
    daraxt(n);
  }
  static void daraxt(int n) {
    if(n<4)
      System.out.println("NO");
    else {
      int x=n;
      System.out.println("YES");
      if (n%2!=0) {
        while(n>5) {
          System.out.printf("%d - %d = 1\n",n,n-1); n-=2;
        }
        for(int i=0;i<(x-5)/2;i++)
          System.out.println("1 * 1 = 1");
        System.out.println("3 - 2 = 1\n5 + 1 = 6\n6 * 1 = 6\n6 * 4 = 24");
      }
      else {
        while(n>4) {
          System.out.printf("%d - %d = 1\n",n,n-1); n-=2;
        }
        for(int i=0;i<(x-4)/2;i++)
          System.out.println("1 * 1 = 1");
        System.out.println("2 * 1 = 2\n2 * 3 = 6\n6 * 4 = 24");
      }
    }
  }
}


import java.util.Scanner;
public class a {
  static Scanner in=new Scanner(System.in);
  public static void main(String[] args) {
    int n=in.nextInt();
    daraxt(n);
  }
  static void daraxt(int n) {
    if(n<4)
      System.out.println("NO");
    else {
      int x=n,s=(n%2==0?4:5),s1=(x%2==0)?(x-4)/2:(x-5)/2;
      System.out.println("YES");
      while(n >s) {
        System.out.printf("%d - %d = 1\n",n,n-1); n-=2;
      }
      for(int i=0;i<s1;i++)
        System.out.println("1 * 1 = 1");
      System.out.println(x%2==0?"2 * 1 = 2\n2 * 3 = 6\n6 * 4 = 24":"3 - 2 = 1\n5 + 1 = 6\n6 * 1 = 6\n6 * 4 = 24");
    }
  }
}


import java.util.Scanner;
public class a {
  static Scanner in=new Scanner(System.in);
  public static void main(String[] args) {
    int n=in.nextInt();
    daraxt(n);
  }
  static void daraxt(int n) {
    if(n<4)
      System.out.println("NO");
    else {
      System.out.println("YES");
      if (n%2!=0) {
        int x=n;
        while(n>5) {
          System.out.println(n+" - "+(n-1)+" = " + "1");
          n-=2;
        }
        for(int i=0;i<(x-5)/2;i++)
          System.out.println("1 * 1 = 1");
        System.out.println("3 - 2 = 1");
        System.out.println("5 + 1 = 6");
        System.out.println("6 * 1 = 6");
        System.out.println("6 * 4 = 24");
      }
      else {
        int x=n;
        while(n>4) {
          System.out.println(n+" - "+(n-1)+" = " + "1");
          n-=2;
        }
        for(int i=0;i<(x-4)/2;i++)
          System.out.println("1 * 1 = 1");
        System.out.println("2 * 1 = 2");
        System.out.println("2 * 3 = 6");
        System.out.println("6 * 4 = 24");
      }
    }
  }
}


import java.util.Scanner;

public class A468 {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int N = input.nextInt();
        if (N < 4) {
            System.out.println("NO");
        } else {
            System.out.println("YES");
            if (N%2 == 0) {
                System.out.println("1 * 2 = 2");
                System.out.println("2 * 3 = 6");
                System.out.println("6 * 4 = 24");
            } else {
                System.out.println("3 + 5 = 8");
                System.out.println("4 - 2 = 2");
                System.out.println("2 + 1 = 3");
                System.out.println("3 * 8 = 24");
            }
            StringBuilder output = new StringBuilder();
            for (int n=N; n>5; n-=2) {
                output.append(n).append(" - ").append(n-1).append(" = 1\n");
                output.append("24 * 1 = 24\n");
            }
            System.out.print(output);
        }
    }

}