#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
int main(int argc, char *argv[]) {
  vector<long long> cnt(60, 0);
  int n;
  cin >> n;
  long long ret = 0;
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    long long b = 1;
    for (int j = 0; j < 60; j++) {
      if ((b & a) == 0) {
        ret = (ret + cnt[j] * b) % MOD;
      } else {
        ret = (ret + (i - cnt[j]) * b) % MOD;
        cnt[j]++;
      }
      b <<= 1;
    }
  }
  cout << ret << endl;
}
