#include <bits/stdc++.h>
using namespace std;
long n, ans = 0, mod = 1000000007;
int main() {
  cin >> n;
  vector<long> a(n);
  vector<long> x(60);
  vector<long> y(60);
  vector<long> two(60);
  for (long i = 0; i < n; i++) cin >> a[i];
  two[0] = 1;
  for (long i = 1; i < 60; i++) two[i] = two[i - 1] * 2;
  for (long i = 0; i < n; i++) {
    for (long j = 0; j < 60; j++) {
      if (a[i] & two[j]) {
        y[j] += i - x[j];
        x[j]++;
      } else {
        y[j] += x[j];
      }
    }
  }
  for (long i = 0; i < 60; i++) {
    ans = (ans + y[i] * (two[i] % mod) % mod) % mod;
  }
  cout << ans << endl;
}
