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