#include <bits/stdc++.h>
using namespace std;
unsigned long long int mod_pow(unsigned long long int n,
                               unsigned long long int p,
                               unsigned long long int mod) {
  unsigned long long int res = 1;
  while (p > 0) {
    if (p & 1) {
      res = res * n % mod;
    }
    n = n * n % mod;
    p >>= 1;
  }
  return res;
}
int main() {
  unsigned long long int n;
  cin >> n;
  unsigned long long int a[n];
  for (unsigned long long int i = 0; i < n; i++) {
    cin >> a[i];
  };
  unsigned long long int zero_count[61] = {0};
  unsigned long long int one_count[61] = {0};
  for (unsigned long long int i = 0; i < n; i++) {
    unsigned long long int x = a[i];
    for (unsigned long long int j = 0; j < 61; j++) {
      if (x & 1) {
        one_count[j]++;
      } else {
        zero_count[j]++;
      }
      x = x >> 1;
    }
  }
  unsigned long long int mod = 1000000007;
  unsigned long long int ans = 0;
  for (unsigned long long int i = 0; i < n; i++) {
    unsigned long long int x = a[i];
    for (unsigned long long int j = 0; j < 61; j++) {
      if (one_count[j] == 0 || zero_count[j] == 0) continue;
      if (x & 1) {
        one_count[j]--;
        ans += mod_pow(2, j, mod) * zero_count[j] % mod;
      } else {
        zero_count[j]--;
        ans += mod_pow(2, j, mod) * one_count[j] % mod;
      }
      x = (x >> 1);
    }
  }
  cout << ans << endl;
}
