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.util.*;
import java.math.*;
import java.io.*;
import java.text.*;

public class A{

static class Node implements Comparable<Node>{
	int id;
	int x;
	public  Node(int id,int x) {
		this.id=id;
		this.x=x;
		
	}
	public int compareTo(Node c) {
		return c.x-this.x;
	}
}
//public static PrintWriter pw; 
public static PrintWriter pw=new PrintWriter(System.out);
public static void solve() throws IOException{
//	pw=new PrintWriter(new FileWriter("C:\\Users\\shree\\Downloads\\small_output_in"));
	FastReader sc=new FastReader();
	int n=sc.I(); 
	long p[]=new long[n+1];
	for(int i=1;i<=n;i++)p[i]=sc.L();
	long xor[]=new long[n+1];
	
	for(int i=1;i<=n;i++) {
		xor[i]=xor[i-1]^i;
	}
	long ans=0;
	for(int i=1;i<=n;i++) {
		if((n/i)%2!=0) ans=(ans^p[i]^xor[i-1]^xor[n%i]); else ans=(ans^p[i]^xor[n%i]);
	}
	pw.println(ans);
	pw.close();
}
static boolean isOk(char s[],char c,int i) {
	return !((i-1>=0 && c==s[i-1]) || (i-2>=0 && c==s[i-2]) );
}
static int upper_bound(long a[],int n,long x) {
	int l=0;
	int h=n;
	while(l<h) {
		int mid=(l+h)/2;
		if(x>=a[mid]) l=mid+1;
		else h=mid;
	}
	return l;
}
public static void main(String[] args)  {
    new Thread(null ,new Runnable(){ 
      public void run(){
          try{
          
              solve();
          } catch(Exception e){
              e.printStackTrace();
          }
      }
  },"1",1<<26).start();
 
}

static long modPow(long x,long y,long M){
	if(y==0) return 1;
	if(y%2==0) return modPow((x*x)%M,y/2,M)%M;
	else return (x*modPow((x*x)%M,(y-1)/2,M))%M;
}

static long M=(long)1e9+7;
 
	static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() throws FileNotFoundException{
            //br=new BufferedReader(new FileReader("C:\\Users\\shree\\Downloads\\B-small-practice.in"));	
        	 br = new BufferedReader(new InputStreamReader(System.in));
        		
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
       
        int I(){   return Integer.parseInt(next()); }
        long L(){  return Long.parseLong(next()); }
        double D() {  return Double.parseDouble(next()); }
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
     }
}