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