#include <bits/stdc++.h>
using namespace std;
long long const mod = 1000000007ll;
int main() {
  int N;
  cin >> N;
  vector<int> d(60, 0);
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    for (int j = 0; j < 60; j++) {
      if (A[i] & (1ll << j)) d[j]++;
    }
  }
  long long sum = 0ll;
  for (int i = 0; i < N; i++) {
    long long k = 1ll;
    long long tmp = 1ll;
    for (int j = 0; j < 60; j++) {
      if (A[i] & (1ll << j)) {
        tmp = (tmp * k) % mod;
        tmp = (tmp * (long long)(N - i - d[j])) % mod;
        d[j]--;
      } else {
        tmp = (tmp * k) % mod;
        tmp = (tmp * (long long)d[j]) % mod;
      }
      k *= 2;
      sum = (sum + tmp) % mod;
    }
  }
  cout << sum << endl;
  return 0;
}
