#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using namespace std;
const ll mod = 1e9 + 7;
int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  map<int, ll> mp;
  for (int(i) = (0); (i) < (int)(N); ++(i)) {
    cin >> A[i];
    ll tmp = A[i];
    ll b = 0;
    while (tmp > 0) {
      if (tmp & 1)
        mp[b]++;
      else
        mp[b];
      b++;
      tmp /= 2LL;
    }
  }
  ll ans = 0;
  ll sz = N - 1;
  for (int(i) = (0); (i) < (int)(sz); ++(i)) {
    ll b = 1;
    for (auto& tmp : mp) {
      if ((A[i] >> tmp.first) & 1) {
        ans += (N - tmp.second) * b;
        tmp.second--;
      } else {
        ans += tmp.second * b;
      }
      ans %= mod;
      b *= 2LL;
    }
    N--;
  }
  cout << ans << endl;
}
