#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
ll mult(ll a, ll b) { return (a * 1LL * b) % (ll)(1e9 + 7); }
ll add(ll a, ll b) { return (a + b) % (ll)(1e9 + 7); }
int main() {
  ll n;
  cin >> n;
  ll a[n], ar[61][n];
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    for (ll j = 0; j <= 60; j++) {
      if ((a[i] >> j) & 1) {
        ar[j][i] = 1;
      } else {
        ar[j][i] = 0;
      }
    }
  }
  for (ll i = n - 2; i >= 0; i--) {
    for (ll j = 0; j <= 60; j++) {
      ar[j][i] += ar[j][i + 1];
    }
  }
  ll ans = 0;
  for (ll i = 0; i < n - 1; i++) {
    ll x = n - i - 1;
    for (ll j = 0; j <= 60; j++) {
      if ((a[i] >> j) & 1) {
        ans = add(ans, mult(x - ar[j][i + 1], (1LL << j)));
      } else {
        ans = add(ans, mult(ar[j][i + 1], (1LL << j)));
      }
    }
  }
  cout << ans << "\n";
}
