#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
int main() {
  int N;
  cin >> N;
  vector<long long int> A(N);
  map<long long int, vector<long long int> > mp;
  long long int pow = 1;
  while (pow <= ((long long int)1 << 61)) {
    mp[pow].push_back(0);
    pow *= 2;
  }
  for (int n = 0; n < N; n++) {
    cin >> A[n];
    pow = 1;
    while (pow <= ((long long int)1 << 61)) {
      if (pow & A[n]) {
        mp[pow].push_back(mp[pow][mp[pow].size() - 1] + 1);
      } else {
        mp[pow].push_back(mp[pow][mp[pow].size() - 1]);
      }
      pow *= 2;
    }
  }
  long long int ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    long long int tmp = 0;
    for (int i = 1; i < itr->second.size() - 1; i++) {
      if (A[i - 1] & itr->first) {
        tmp += (N - i) - (itr->second[itr->second.size() - 1] - itr->second[i]);
      } else {
        tmp += itr->second[itr->second.size() - 1] - itr->second[i];
      }
    }
    tmp %= MOD;
    ans += tmp * itr->first;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}
