#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
const ll mod = 1e9 + 7;
ll a[300005], ans;
ll dp[65];
int main() {
  ll n;
  cin >> n;
  for (ll i = 1; i <= n; i++) cin >> a[i];
  for (ll i = 0; i <= 60; i++) {
    ll f1 = 0, f0 = 0, k = 0;
    for (ll j = 1; j <= n; j++) {
      if (a[j] & (1ll << i))
        f1++, k = 1;
      else
        f0++;
      if (a[j] & (1ll << i) && k)
        ans += (f0 * ((1ll << i)));
      else if (k)
        ans += (f1 * ((1ll << i)));
      ans %= mod;
    }
  }
  cout << ans << endl;
}
