#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long> a(n);
  int i;
  long s = 0;
  long ans = 0;
  long const p = 1000000007;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    s += a[i];
    s %= p;
  }
  ans += (n - 1) * s % p;
  for (long bit = 1; bit <= (1LL << 60); bit *= 2) {
    long bitNum = 0;
    for (i = 0; i < n; i++) {
      if (bit & a[i]) bitNum++;
    }
    if (bitNum >= 2) {
      ans -= (bit % p) * (bitNum * (bitNum - 1)) % p;
      while (ans < 0) ans += p;
    }
  }
  cout << ans % p << endl;
}
