#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int64_t HEX = 1LL << 16, Z = pow(HEX, 3) + pow(HEX, 2) + HEX + 1;
int main() {
  int64_t A = 0, N, x, y;
  vector<int64_t> bit(16, 0);
  cin >> N;
  while (cin >> x)
    for (int i = 0; i < (int)16; i++) bit.at(i) += x & Z, x >>= 1;
  for (int i = 0; i < (int)16; i++) {
    x = bit.at(i);
    for (int j = 0; j < (int)4; j++) {
      y = x & HEX - 1;
      x /= HEX;
      A += (1LL << (16 * j + i)) % MOD * y % MOD * (N - y) % MOD;
    }
  }
  return cout << A % MOD << endl, 0;
}
