#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  long long K = ceil(log2(max((long long)1, *max_element(A.begin(), A.end()))));
  vector<pair<long long, long long> > nums(K);
  vector<pair<long long, long long> > ks(K);
  for (int i = 0; i < K; i++) {
    ks[i].first = i;
    ks[i].second = pow(2, i);
  }
  for (int i = 0; i < N; i++) {
    long long a = A[i];
    for (auto& p : ks) {
      bool n = (a & p.second) > 0;
      if (n == 0)
        nums[p.first].first += 1;
      else
        nums[p.first].second += 1;
    }
  }
  long long ans = 0;
  for (auto& a : A) {
    for (auto& p : ks) {
      bool n = (a & p.second) > 0;
      if (n == 0) {
        nums[p.first].first -= 1;
        ans += p.second * nums[p.first].second % MOD;
      } else {
        nums[p.first].second -= 1;
        ans += p.second * nums[p.first].first % MOD;
      }
    }
  }
  cout << ans % MOD << endl;
  return 0;
}
