#include <bits/stdc++.h>
#pragma GCC optimize("O4")
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll fpow(ll b, ll p) {
  b %= (ll)(1e9 + 7);
  ll ans = 1;
  while (p > 0) {
    if (p & 1) ans = (ans * b) % (ll)(1e9 + 7);
    p /= 2;
    b = (b * b) % (ll)(1e9 + 7);
  }
  return ans;
}
ll res[15][15];
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  ll cnt[65] = {0};
  ll ans = 0;
  for (ll i = 0; i <= n - 1; i++) {
    ll t;
    cin >> t;
    for (ll j = 0; j <= 60; j++) {
      if (t & (1ll << j))
        ans += (1ll << j) * (i - cnt[j]);
      else
        ans += (1ll << j) * (cnt[j]);
      if (t & (1ll << j)) cnt[j]++;
      ans %= (ll)(1e9 + 7);
    }
  }
  cout << ans << "\n";
  return 0;
}
