#include <bits/stdc++.h>
long long int sumXOR(long long arr[], long long n) {
  long long M = 1e9;
  long long int sum = 0;
  for (int i = 0; i < 32; i++) {
    int zc = 0, oc = 0;
    long long int idsum = 0;
    for (int j = 0; j < n; j++) {
      if (arr[j] % 2 == 0)
        zc++;
      else
        oc++;
      arr[j] /= 2;
    }
    idsum = oc * zc * (1 << i);
    sum += idsum % M;
  }
  return sum;
}
using namespace std;
int main() {
  long long n, sum = 0;
  long long M = 1e9;
  cin >> n;
  long long a[n + 1];
  for (int i = 0; i < n; i++) cin >> a[i];
  cout << sumXOR(a, n) % M << endl;
}
