#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9;
int main() {
  int n;
  cin >> n;
  long long a[300002], sum = 0;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      sum += (a[i] ^ a[j]);
      sum %= mod;
    }
  }
  cout << sum << endl;
}
