#include <bits/stdc++.h>
const int inf = (1 << 30);
using ll = long long;
const ll mod = 1000000007;
using namespace std;
int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (auto &k : a) cin >> k;
  ll ans = 0;
  for (int i = 0; i < 62; ++i) {
    ll nll = 0, eins = 0;
    for (int k = 0; k < n; ++k) {
      if (a[k] & (1ll << i))
        ++eins;
      else
        ++nll;
    }
    ans += ((1ll << i) % mod *
            (n * (n - 1) / 2 + 3 * mod -
             (max(0ll, eins * (eins - 1) / 2) % mod +
              max(0ll, nll * (nll - 1) / 2) % mod) %
                 mod) %
            mod) %
           mod;
  }
  cout << ans % mod << endl;
}
