#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 1e9 + 7;
constexpr int64_t DECADE = 1LL << 10, Z = (1LL << 0) | (1LL << 10) |
                                          (1LL << 20) | (1LL << 30) |
                                          (1LL << 40) | (1LL << 50);
int main() {
  int N;
  int64_t A = 0, x, y;
  vector<int64_t> bit(10, 0);
  cin >> N;
  while (cin >> x)
    for (int64_t i = 0; i < (int)10; i++) bit.at(i) += x >> i & Z, x >> 1;
  for (int64_t i = 0; i < (int)10; i++) {
    x = bit.at(i);
    for (int64_t j = 0; j < (int)6; j++) {
      y = x & DECADE - 1;
      x /= DECADE;
      A = fmod(A + fmod(y % MOD * (N - y) % MOD * pow(2, i + 10 * j), MOD),
               MOD);
    }
  }
  return cout << A << endl, 0;
}
