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.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeSet;



public class Main {
	class Point implements Comparable<Point>{
		int x;
		int y;
		public int pop;
		public double  norm;
		public Point(int x,int y,int p){
			this.x=x;
			this.y=y;
			this.pop=p;
			norm=Math.sqrt(x*x+y*y);
		}
		@Override
		public int compareTo(Point p) {
			if (norm>p.norm) return 1;
			if (norm<p.norm) return -1;
			return 0;
		}
		
	}
	/**
	 * @param args
	 */
	 BufferedReader in;
	    PrintWriter out = new PrintWriter(System.out);
	    StringTokenizer tok;
	   
	     String readToken() throws IOException { // reads the token; to read a full line use in.readLine()
	    while (tok == null || !tok.hasMoreTokens()) {
	    tok = new StringTokenizer(in.readLine());
	    	
	    }
	    return tok.nextToken(); // sometimes it's better to use nextToken(String) method here
	    }
	     int readInt() throws IOException { // write readDouble(), readLong(), readBigInteger() methods if necessary
	    return Integer.parseInt(readToken());
	    }
	     public String readLine() throws IOException{
			return in.readLine();
	    	 
	     }
	     long readLong() throws IOException { // write readDouble(), readLong(), readBigInteger() methods if necessary
	    	    return Long.parseLong(readToken());
	    	    }
	     double readDouble() throws IOException { // write readDouble(), readLong(), readBigInteger() methods if necessary
	    	    return Double.parseDouble(readToken());
	    	    }
	    public static void main(String[] args) throws IOException
	    {
	       new Main().run();
	    }
	    void run() throws IOException
	    {
	    	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	    	out = new PrintWriter(new OutputStreamWriter(System.out));
	    	in = new BufferedReader(new InputStreamReader(System.in));
	    	if (oj){
	    
	    	}
	    	else{
	    		
	    		
	    	}
	       solve();
	       out.flush();
	       tok=null;
	    }
	  
	    
	    void solve() throws IOException{
	    	int n=readInt();
	    	long ans=readInt();
	    	for (int i=1;i<n;i++){
	    		ans=ans^readInt();
	    	}
	    	long[] A=new long[n+1];
	    	long[] B=new long[n+1];
	    	A[0]=0;
	    	B[0]=0;
	    	B[1]=1;
	    	
	    	for (int i=1;i<=n;i++){
	    		A[i]=A[i-1]^i;
	    		if (i>1){
	    			B[i]=B[i-1]^i;
	    		}
	    		int die=n/i;
	    		long tX;
	    		if (die % 2==0){
	    			tX=0;
	    		}else{
	    			tX=0^A[i-1];
	    		}
	    		int x=n % i;
	    		if (x>0){
	    			tX=tX^B[x];
	    		}
	    		ans=ans^tX;
	    		
	    	}
	    	out.println(ans);
	    }
	    
}