#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1000005;
int v[SIZE], t[SIZE];
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    int data, res;
    for (int i = 0; i < n; i++) {
      scanf("%d", &data);
      if (i == 0)
        res = data;
      else
        res = res ^ data;
    }
    int tmp = 0;
    v[0] = 0;
    t[1] = 1;
    for (int i = 2; i <= n; i++) {
      t[i] = t[i - 1] ^ i;
    }
    for (int i = 1; i < n; i++) {
      v[i] = v[i - 1] ^ i;
    }
    int res2 = -1;
    for (int i = 1; i <= n; i++) {
      int tmp;
      int mid = n / i % 2;
      if (mid == 0) {
        tmp = 0;
      } else {
        tmp = v[i - 1];
      }
      if ((n % i != 0)) {
        tmp = tmp ^ t[n % i];
      }
      if (res2 == -1)
        res2 = tmp;
      else
        res2 = res2 ^ tmp;
    }
    printf("%d\n", res ^ res2);
  }
  return 0;
}
