#include <bits/stdc++.h>
using namespace std;
int pre[1001010];
int n;
int x, ans;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    pre[i] = pre[i - 1] ^ i;
  }
  for (int i = 1; i <= n; i++) {
    cin >> x;
    ans ^= (x ^ pre[n % i] ^ ((n / i) % 2 ? pre[i - 1] : 0));
  }
  cout << ans << endl;
  return 0;
}
