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.util.*;

public class ProblemEE {

  
  public static void main(String[] args) throws Exception {
    ParserdoubtEE in = new ParserdoubtEE(System.in);
    
    int n = in.nextInt();
    long a[] = new long[n];
    for (int i = 0; i < a.length; i++) {
      a[i] = in.nextLong();
    }
    
    long res = a[0];
    for (int i = 1; i < a.length; i++) {
      res ^= a[i];
    }
    
    
    long N = n;
    for (long mod = 1; mod <= N; mod++) {
      
      long off = N % mod;
      
      res ^= xor1N(off);
      
      long m = N - off;
      m /= mod;
      if(m % 2 == 1) {
        res ^= xor1N(mod - 1);
      }
      // System.out.println(mod + " " + off + " " + m);
      // System.out.println(mod + " " + xor1N(off) + " " + xor1N(mod-1) );
      // System.out.println();
    }
    
    System.out.println(res);
    
  }
  
  static long xor1N(long N) {
    return N & ((N % 2 > 0) ? 0 : ~0) | ( ((N & 2)>>1) ^ (N & 1));
  }
}


class ParserdoubtEE
{
   final private int BUFFER_SIZE = 1 << 17;
 
   private DataInputStream din;
   private byte[] buffer;
   private int bufferPointer, bytesRead;
 
   public ParserdoubtEE(InputStream in)
   {
      din = new DataInputStream(in);
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
   }
   public String nextString() throws Exception
   {
       StringBuffer sb=new StringBuffer("");
       byte c = read();
       while (c <= ' ') c = read();
       do
       {
           sb.append((char)c);
           c=read();
       }while(c>' ');
       return sb.toString();
   }
   public char nextChar() throws Exception
   {
       byte c=read();
       while(c<=' ') c= read();
       return (char)c;
   }
   public int nextInt() throws Exception
   {
      int ret = 0;
      byte c = read();
      while (c <= ' ') c = read();
      boolean neg = c == '-';
      if (neg) c = read();
      do
      {
          ret = ret * 10 + c - '0';
         c = read();
      } while (c > ' ');
      if (neg) return -ret;
      return ret;
   }
   public long nextLong() throws Exception
   {
      long ret = 0;
      byte c = read();
      while (c <= ' ') c = read();
      boolean neg = c == '-';
      if (neg) c = read();
      do
      {
          ret = ret * 10 + c - '0';
         c = read();
      } while (c > ' ');
      if (neg) return -ret;
      return ret;
   }
   private void fillBuffer() throws Exception
   {
      bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
      if (bytesRead == -1) buffer[0] = -1;
   }
 
   private byte read() throws Exception
   {
      if (bufferPointer == bytesRead) fillBuffer();
      return buffer[bufferPointer++];
   }
} 