#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int P = 1000000007;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  ll s[60] = {};
  int p[60] = {};
  for (int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    ll t = 1;
    for (int k = 0; k < 60; k++) {
      s[k] += (a & t) ? i - p[k]++ : p[k];
      t <<= 1;
    }
  }
  ll r = 0;
  for (int k = 0; k < 60; k++) {
    r += (1LL << k) % P * s[k] % P;
  }
  r %= P;
  cout << r << endl;
  return 0;
}
