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.*;
import java.lang.reflect.Array;
import java.util.*;
import static java.lang.Integer.min;
import static java.lang.Long.max;

public final class Main {
        static FastScanner in=new FastScanner();
        static PrintWriter out=new PrintWriter(System.out);


        /*
        Never use sorting on 1-indexed array! or be very careful about negative values and stuff
        read the statement carefully!
        What about corner cases a=0?
        */
        public static void main(String[]args) {
                int n=in.nextInt();
                int ans=0;
                for (int i=1;i<=n;i++){
                        ans^=in.nextInt();
                }

                int[]x=new int[n+1];
                x[0]=0;
                for (int i=1;i<=n;i++)x[i]=x[i-1]^i;

                for (int i=1;i<=n;i++){
                        int rem=n%i;
                        ans^=x[rem];
                        if((n/i)%2==1)ans^=x[i-1];
                }

                out.println(ans);
                out.close();
        }




        static long lcm(long a,long b, long c){
                return lcm(a,lcm(b,c));
        }
        static long lcm(long a,long b){
                return a*b/gcd(a,b);
        }
        static long gcd(long a,long b) {
                if (a == 0) return b;
                return gcd(b%a,a);
        }
        static void printArray(long[]a,int m){
                for (int i=m;i<a.length+m;i++)out.print(a[i]+" ");
                out.println();
        }
        static void printArray(int[]a,int m){
                for (int i=m;i<a.length+m;i++)out.print(a[i]+" ");
                out.println();
        }
        static void printArray(String[]a,int m){
                for (int i=m;i<a.length+m;i++)out.print(a[i]+" ");
                out.println();
        }
        static void printArray(double[]a,int m){
                for (int i=m;i<a.length+m;i++)out.print(a[i]+" ");
                out.println();
        }
        static void printArray(boolean[]a,int m){
                for (int i=m;i<a.length+m;i++)out.print(a[i]+" ");
                out.println();
        }
        static class Pair implements Comparable<Pair>{
                int first,second;
                public Pair(int a,int b) {
                        first=a;
                        second=b;
                }
                @Override
                public int compareTo(Pair o) {
                        return first-o.first;
                }
        }
        static class FastScanner{
                BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
                StringTokenizer st=new StringTokenizer("");
                String next(){
                        while(!st.hasMoreTokens())
                                try{
                                        st=new StringTokenizer(br.readLine());
                                }catch(IOException e){
                                        e.printStackTrace();
                                }
                        return st.nextToken();
                }
                int nextInt() {
                        return Integer.parseInt(next());
                }
                int[] nextArray(int n,int m) {
                        int[] a=new int[n+m];
                        for (int i=m;i<n+m;i++)a[i]=nextInt();
                        return a;
                }
                long nextLong() {
                        return Long.parseLong(next());
                }
                double nextDouble() {
                        return Double.parseDouble(next());
                }
        }
}