#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 5;
const long long BITS = 61;
const long long MOD = 1e9 + 7;
long long suffix[N][BITS], a[N];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = n; i > 0; i--) {
    for (long long j = 0; j < BITS; j++) {
      suffix[i][j] += suffix[i + 1][j];
      suffix[i][j] += (a[i] >> j) & 1;
    }
  }
  long long ans = 0;
  for (long long i = 1; i < n; i++) {
    for (long long j = 0; j < BITS; j++) {
      if ((a[i] >> j) & 1) {
        long long temp = (1LL << j) * (n - i - suffix[i + 1][j]) % MOD;
        ans += temp;
        ans %= MOD;
      } else {
        long long temp = (1LL << j) * suffix[i + 1][j] % MOD;
        ans += temp;
        ans %= MOD;
      }
    }
  }
  cout << ans;
  return 0;
}
