#include <iostream>
#include <vector>
using namespace std;

constexpr unsigned long long m = 1'000'000'000 + 7;

int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i];

  int counters[60][2] = {};
  for (int bitpos = 0; bitpos < 60; ++bitpos) {
    long long bit = 1LL << bitpos;
    for (int i = 0; i < n; ++i)
      ++counters[bitpos][a[i] & bit ? 1 : 0];
  }

  long long sum = 0;
  for (int bitpos = 0; bitpos < 60; ++bitpos) {
    long long bit = 1LL << bitpos;
    for (int i = 0; i < n; ++i) {
      int c = counters[bitpos][a[i] & bit ? 1 : 0];
      sum += c * (bit % (2 * m));
      sum %= (2 * m);
    }
  }

  cout << (sum/2);
  return 0;
}
