#include <bits/stdc++.h>
using namespace std;
long long n;
long long p;
long long xorr[1000005], xorr2[1000005];
;
int main() {
  cin >> n;
  long long res = 0;
  for (int i = 0; i < n; i++) {
    cin >> p;
    res ^= p;
  }
  xorr[0] = 0;
  for (int i = 1; i <= n; i++) xorr[i] = i ^ xorr[i - 1];
  for (int k = 1; k <= n; k++) {
    long long cur;
    switch ((k - 1) % 4) {
      case 0:
        cur = k - 1;
        break;
      case 1:
        cur = 1;
        break;
      case 2:
        cur = k;
        break;
      case 3:
        cur = 0;
        break;
    }
    long long ncur;
    switch ((n % k) % 4) {
      case 0:
        ncur = n % k;
        break;
      case 1:
        ncur = 1;
        break;
      case 2:
        ncur = (n % k) + 1;
        break;
      case 3:
        ncur = 0;
        break;
    }
    if ((n / k) & 1) res ^= cur;
    res ^= ncur;
  }
  cout << res;
  return 0;
}
