#include <bits/stdc++.h>
using namespace std;
int bitsOne[60][300000] = {0};
unsigned long long A[300000];
int main() {
  int N, shift = 0;
  unsigned long long mul = 1, ans = 0;
  cin >> N;
  for (int i = 0; i < (N); i++) cin >> A[i];
  for (int i = 0; i < (60); i++) {
    for (int j = (N)-1; j >= 0; j--) {
      if (j == N - 1) {
        if (((A[j] >> shift) & 1) == 1) bitsOne[i][j] = 1;
      } else {
        if (((A[j] >> shift) & 1) == 1)
          bitsOne[i][j] = bitsOne[i][j + 1] + 1;
        else
          bitsOne[i][j] = bitsOne[i][j + 1];
      }
    }
    shift++;
  }
  shift = 0;
  for (int i = 0; i < (60); i++) {
    for (int j = 0; j < (N - 1); j++) {
      unsigned long long add;
      if (((A[j] >> shift) & 1) == 0)
        add = (bitsOne[i][j + 1]) % (1000000007);
      else
        add = (N - j - 1 - bitsOne[i][j + 1]) % (1000000007);
      add = (add * mul) % (1000000007);
      ans = (ans + add) % (1000000007);
    }
    shift++;
    mul *= 2;
  }
  cout << ans << endl;
  return 0;
}
