#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, A[300001], mod = 1e9 + 7;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> A[i];
  long long B[70] = {0};
  for (int i = 0; i < n; i++) {
    long long p = A[i];
    for (int j = 0; p > 0; j++) {
      B[j] += p % 2;
      p = p / 2;
    }
  }
  long long x = 0;
  for (int i = 0; i < 61; i++) {
    x = (x + B[i] * (B[i] - 1) / 2 % mod * long long(pow(2, i)) % mod) % mod;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) ans = (ans + A[i]) % mod;
  ans = (n - 1) * ans % mod;
  ans = (ans - 2 * x + 2 * mod) % mod;
  cout << ans;
}
