#include <bits/stdc++.h>
using namespace std;
int myXOR(long long, long long);
int main() {
  long long n;
  cin >> n;
  long long a[n];
  long long i, j;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long count = 0;
  for (i = 0; i < n - 1; i++) {
    for (j = i + 1; j < n; j++) {
      long long x = a[i];
      long long y = a[j];
      count += myXOR(x, y) % (1000000007);
    }
  }
  cout << count << "\n";
}
int myXOR(long long x, long long y) {
  long long res = 0;
  for (long long i = 31; i >= 0; i--) {
    bool b1 = x & (1 << i);
    bool b2 = y & (1 << i);
    bool xoredBit = (b1 & b2) ? 0 : (b1 | b2);
    res <<= 1;
    res |= xoredBit;
  }
  return res;
}
