#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
ll A[300000];
int cnt[300000][60];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    for (int j = 0; j < 60; j++) {
      cnt[i][j] = (A[i] >> j) & 1;
    }
    if (i > 0) {
      for (int j = 0; j < 60; j++) cnt[i][j] += cnt[i - 1][j];
    }
  }
  ll ans = 0;
  for (int i = 1; i < N; i++) {
    for (int j = 0; j < 60; j++) {
      if ((A[i] >> j) & 1) {
        (ans += (1LL << j) * (i - cnt[i - 1][j]) % mod) %= mod;
      } else {
        (ans += (1LL << j) * cnt[i - 1][j] % mod) %= mod;
      }
    }
  }
  cout << ans << endl;
}
