#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int const MAX = 3e+5;
ll const MOD = (ll)1e+9 + 7;
P table[MAX + 1][64];
void solve() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < (N); ++i) cin >> A[i];
  for (int i = N - 1; i >= 0; i--) {
    ll t = A[i];
    int j = 0;
    while (j < 63) {
      int a = t & 1;
      int zero = table[i + 1][j].first;
      int one = table[i + 1][j].second;
      if (a)
        one++;
      else
        zero++;
      table[i][j] = {zero, one};
      j++;
      t /= 2;
    }
  }
  ll ans = 0;
  for (int i = 0; i < (N); ++i) {
    for (int j = 0; j < (63); ++j) {
      if ((A[i] >> j) & 1) {
        ans = (ans + (1ll << j) * (ll)table[i][j].first) % MOD;
      } else {
        ans = (ans + (1ll << j) * (ll)table[i][j].second) % MOD;
      }
    }
  }
  cout << ans << endl;
  return;
}
int main() {
  solve();
  return 0;
}
