#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7, MAX_N = 30006;
int N;
ll A[MAX_N];
ll bit0[70], bit1[70];
void solve() {
  ll x = A[N - 1];
  for (int i = 0; i < 62; ++i) {
    if (x >> i & 1)
      bit1[i]++;
    else
      bit0[i]++;
  }
  ll res = 0;
  for (int i = N - 2; i >= 0; --i) {
    ll x = A[i];
    for (int j = 0; j < 62; ++j) {
      if (x >> j & 1)
        res = (res + (bit0[j] % MOD) * ((1LL << j) % MOD)) % MOD, bit1[j] += 1;
      else
        res = (res + (bit1[j] % MOD) * ((1LL << j) % MOD)) % MOD, bit0[j] += 1;
    }
  }
  cout << res << "\n";
}
int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> A[i];
  solve();
  return 0;
}
