People in the Tomskaya region like magic formulas very much. You can see some of them below.

Imagine you are given a sequence of positive integer numbers p1, p2, ..., pn. Lets write down some magic formulas:

<image><image>

Here, "mod" means the operation of taking the residue after dividing.

The expression <image> means applying the bitwise xor (excluding "OR") operation to integers x and y. The given operation exists in all modern programming languages. For example, in languages C++ and Java it is represented by "^", in Pascal — by "xor".

People in the Tomskaya region like magic formulas very much, but they don't like to calculate them! Therefore you are given the sequence p, calculate the value of Q.

Input

The first line of the input contains the only integer n (1 ≤ n ≤ 106). The next line contains n integers: p1, p2, ..., pn (0 ≤ pi ≤ 2·109).

Output

The only line of output should contain a single integer — the value of Q.

Examples

Input

3
1 2 3


Output

3
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class C
{
	String line;
	StringTokenizer inputParser;
	BufferedReader is;
	FileInputStream fstream;
	DataInputStream in;
	String FInput="";
	
	
	void openInput(String file)
	{

		if(file==null)is = new BufferedReader(new InputStreamReader(System.in));//stdin
		else
		{
			try{
		
				
			fstream = new FileInputStream(file);
			in = new DataInputStream(fstream);
			is = new BufferedReader(new InputStreamReader(in));
			}catch(Exception e)
			{
				System.err.println(e);
			}
		}

	}
	
	void readNextLine()
	{
		try {
			line = is.readLine();
			inputParser = new StringTokenizer(line, " ");
			//System.err.println("Input: " + line);
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}	
		
	}
	
	int NextInt()
	{
		String n = inputParser.nextToken();
		int val = Integer.parseInt(n);
		
		//System.out.println("I read this number: " + val);
		return val;
	}
	
	String NextString()
	{
		String n = inputParser.nextToken();
		return n;
	}
	
	void closeInput()
	{
		try {
			is.close();
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}
			
	}
	
	public void readFInput()
	{
		for(;;)
		{
			try
			{
				readNextLine();
				FInput+=line+" ";
			}
			catch(Exception e)
			{
				break;
			}
		}
		inputParser = new StringTokenizer(FInput, " ");
	}
	
	long NextLong()
    {
            String n = inputParser.nextToken();
            
            long val = Long.parseLong(n);
            
            return val;
    }
	
	public static void main(String [] argv)
	{
		//String filePath="input.txt";
        String filePath=null;
        if(argv.length>0)filePath=argv[0];
		new C(filePath);
	}
	final int MOD=1000000007;
	int [] ff;
	public C(String inputFile)
	{
		ff = new int[1000001];

		for(int i=1; i<ff.length; i++)
		{
			ff[i]=ff[i-1]^i;
		}

		openInput(inputFile);
		StringBuilder sb = new StringBuilder();
		readNextLine();
		int N=NextInt();
		int [] p = new int[N];
		readNextLine();
		for(int i=0; i<N; i++)
			p[i]=NextInt();
		int Q=0;
		
		
		for(int i=0; i<N; i++)
		{
			Q^=p[i];			
		}
		int q=get3(N);
		Q^=q;
		sb.append(Q);
		System.out.println(sb);
		closeInput();			
	}
	
	private int get3(int x)
	{
		int q=0;
		TreeSet <Integer> A = new TreeSet<Integer>();
		TreeSet <Long> B = new TreeSet<Long>();
		
		for(int j=1; j<=x; j++)
		{
			int last=x%j;
			int rounds=x/j;
			
			//System.out.println("rounds="+rounds);
			if(rounds%2==0)
			{
				if(j*rounds!=x)
				{
					if(A.contains(x%j))A.remove(x%j);
					else A.add(x%j);
				}
			}
			else
			{
				long D=x%j+10000000L*j;
				if(B.contains(D))B.remove(D);
				else B.add(D);
			}
			/*
			for(int i=0; i<x; i++)
			{
				System.out.println((i+1)+" "+j+" "+(i+1)%j);
				//q^=((i+1)%j);
			}*/
			
		}
		for(int y:A)
		{
			
			q^=ff[y];
			
		}
		
		for(long y:B)
		{
			int f=(int) (y%10000000);
			int t=(int) (y/10000000);
			q^=ff[t-1];
			q^=ff[f];
		}
		return q;
	}

	private int get(int x)
	{
		int q=0;
		
		for(int j=1; j<=x; j++)
		{
			int last=x%j;
			int rounds=x/j;
			
			//System.out.println("rounds="+rounds);
			if(rounds%2==0)
			{
				if(j*rounds!=x)
				for(int i=1; i<=last; i++)
				{
					//System.out.println(">>1 "+(i)+" "+j+" "+(i)%j);
					q^=((i));
				}
			}
			else
			{
				for(int i=last+1; i<j; i++)
				{
					//System.out.println(">>2 "+(i)+" "+j+" "+(i)%j);
					q^=((i));
				}
			}
			/*for(int i=0; i<x; i++)
			{
				System.out.println((i+1)+" "+j+" "+(i+1)%j);
				//q^=((i+1)%j);
			}*/
			
		}
		return q;
	}
	
	private int get2(int x)
	{
		int q=0;
		for(int j=1; j<=x; j++)
		{
			
			for(int i=0; i<x; i++)
			{
				//System.out.println((i+1)+" "+j+" "+(i+1)%j);
				q^=((i+1)%j);
			}
			
		}
		return q;
	}
	
		
}

