#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  vector<long long> power_of_two(64);
  power_of_two[0] = 1;
  for (long long i = 1; i < 64; i++) power_of_two[i] = power_of_two[i - 1] * 2;
  vector<vector<bool>> bin(n);
  for (long long i = 0; i < n; i++) bin[i].resize(64);
  for (long long i = 0; i < n; i++) {
    long long x = a[i];
    long long cnt = 0;
    while (x > 0) {
      bin[i][cnt] = x % 2;
      cnt++;
      x /= 2;
    }
  }
  long long ans = 0;
  for (long long i = 0; i < 64; i++) {
    long long ans_for_bit = 0;
    vector<long long> zero(n), unit(n);
    zero[0] = 1 - bin[0][i];
    unit[0] = bin[0][i];
    for (long long j = 1; j < n; j++) {
      zero[j] = zero[j - 1] + (1 - bin[j][i]);
      unit[j] = unit[j - 1] + bin[j][i];
    }
    for (long long j = 1; j < n; j++)
      ans_for_bit += bin[j][i] * zero[j - 1] + (1 - bin[j][i]) * unit[j - 1];
    ans = (ans + (ans_for_bit * (power_of_two[i] % MOD)) % MOD) % MOD;
  }
  cout << ans;
  return 0;
}
