#include <bits/stdc++.h>
using namespace std;
const long long INF = 2e16;
const long long MOD = 1e9 + 7;
const long long MB = 60;
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<long long> bits(MB);
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < MB; j++) {
      if ((a[i] >> j) & 1) bits[j]++;
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n - 1; i++) {
    for (long long j = 0; j < MB; j++) {
      if ((a[i] >> j) & 1) bits[j]--;
    }
    for (long long j = 0; j < MB; j++) {
      if ((a[i] >> j) & 1)
        ans += (1LL << j) * (n - i - 1 - bits[j]);
      else
        ans += (1LL << j) * bits[j];
      ans %= MOD;
    }
  }
  cout << ans % MOD;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed;
  cout.precision(12);
  solve();
}
