#include <bits/stdc++.h>
using namespace std;
unsigned long long mod = 1000000007;
int main() {
  unsigned long long n;
  cin >> n;
  unsigned long long count = 0;
  unsigned long long *arr = new unsigned long long[n];
  unsigned long long *dig = new unsigned long long[n];
  unsigned long long mu = 1;
  int cum = 0;
  int oz[2] = {};
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    dig[i] = 0;
  }
  for (int idx = 0; idx < 64; ++idx) {
    cum = 0;
    oz[0] = 0;
    oz[1] = 0;
    for (int i = 0; i < n; ++i) {
      dig[i] = arr[i] % 2;
      arr[i] >>= 1;
    }
    oz[dig[0]] = 1;
    for (int i = 1; i < n; ++i) {
      cum += oz[dig[i] ? 0 : 1];
      oz[dig[i]] += 1;
    }
    count += cum * (mu % mod);
    mu *= 2;
    count %= mod;
  }
  cout << count;
  return 0;
}
