#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int standard[maxn];
void Init() {
  standard[0] = 0;
  for (int i = 1; i < maxn; i++) standard[i] = standard[i - 1] ^ i;
}
int main() {
  Init();
  int n, p;
  while (~scanf("%d", &n)) {
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &p);
      ans = ans ^ p;
      int w = n / i;
      if (w % 2 == 1) ans = ans ^ standard[i - 1];
      ans ^= standard[n % i];
    }
    printf("%d\n", ans);
  }
  return 0;
}
