#include <bits/stdc++.h>

using namespace std;

constexpr uint64_t mod_base = 1'000'000'007ULL;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  uint64_t n;
  cin >> n;
  vector<uint64_t> nums(n);
  for (uint64_t i = 0; i < n; ++i) {
    cin >> nums[i];
  }

  constexpr uint64_t num_bits = 60;
  vector<vector<uint64_t>> bits(n, vector<uint64_t>(num_bits));
  for (uint64_t i = 0; i < n; ++i) {
    uint64_t idx = 0;
    for (auto x = nums[i]; x; x >>= 1) {
      bits[i][idx] = x & 1;
      ++idx;
    }
  }


  vector<uint64_t> bit_sum = bits.back();
  vector<uint64_t> xor_sum(vector<uint64_t>(num_bits, 0));

  for (uint64_t i = n - 2; i >= 0; --i) {
    auto cnt = n - i - 1;
    for (uint64_t b = 0; b < num_bits; ++b) {
      auto val = bit_sum[b];
      if (bits[i][b]) {
        val = cnt - val;
      }
      xor_sum[b] += val;
    }
    for (uint64_t b = 0; b < num_bits; ++b) {
      bit_sum[b] += bits[i][b];
    }
  }

  uint64_t result = 0;
  uint64_t base = 1;
  for (uint64_t b = 0; b < num_bits; ++b) {
    result += xor_sum[b] * base;
    // cout << " # " << result << endl;
    result %= mod_base;

    base = (base * 2ULL) % mod_base;
    // base = base * 2ULL;
  }


  cout << result << endl;
}
