#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);

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

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


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

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

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

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


  cout << result << endl;
}
