#include <bits/stdc++.h>
using namespace std;
using lint = unsigned long long;
int main(void) {
  lint N;
  cin >> N;
  vector<lint> A(N);
  for (int i = 0; i < (N); i++) cin >> A[i];
  vector<vector<lint>> one(60, vector<lint>(N + 1, 0));
  vector<vector<lint>> zero(60, vector<lint>(N + 1, 0));
  lint mask = 1;
  for (int k = 0; k < 60; k++) {
    one[k][N] = 0;
    zero[k][N] = 0;
    for (int i = N - 1; i >= 0; i--) {
      one[k][i] = one[k][i + 1];
      zero[k][i] = zero[k][i + 1];
      if ((mask & A[i]) == mask) {
        one[k][i]++;
      } else {
        zero[k][i]++;
      }
    }
    mask = mask << 1;
  }
  lint ans = 0;
  mask = 1;
  for (int k = 0; k < 60; k++) {
    for (int i = 0; i < N; i++) {
      if ((mask & A[i]) == mask) {
        ans = (ans + (mask * zero[k][i]) % 1000000007) % 1000000007;
      } else {
        ans = (ans + (mask * one[k][i]) % 1000000007) % 1000000007;
      }
    }
    mask = mask << 1;
  }
  cout << ans << endl;
  return 0;
}
