#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1000000007;
const ll INF = 1LL << 60;
int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  vector<vector<ll>> s(61, vector<ll>(n, 0));
  ll ans = 0;
  for (int k = 0; k < (61); ++k) {
    for (int i = 0; i < (n); ++i) {
      if ((a[i] >> k) & 1) {
        s[k][i] = 1;
      }
      if (i > 0) {
        s[k][i] += s[k][i - 1];
      }
    }
    for (int i = 0; i < (n - 1); ++i) {
      ll cnt = s[k][n - 1] - s[k][i];
      ll tmp;
      if ((a[i] >> k) & 1) {
        tmp = (n - 1 - i - cnt) * (1LL << k);
      } else {
        tmp = cnt * (1LL << k);
      }
      ans = (ans + tmp) % MOD;
    }
  }
  cout << ans << endl;
  return 0;
}
