#include <bits/stdc++.h>
using namespace std;
int main() {
  int DIV = 1e+9 + 7;
  int BIT_REM[60];
  int b = 1;
  for (int i = 0; i < 60; i++) {
    BIT_REM[i] = b;
    b = (b << 1) % DIV;
  }
  int N;
  cin >> N;
  long A[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  long sum = 0;
  for (int i = 0; i < N; i++) sum = (sum + A[i]) % DIV;
  int bit_num_squared = 0;
  for (int j = 0; j < 60; j++) {
    int set_bit_num = 0;
    for (int i = 0; i < N; i++) set_bit_num += (A[i] >> j) & 1;
    bit_num_squared =
        (bit_num_squared + BIT_REM[j] * set_bit_num * set_bit_num) % DIV;
  }
  cout << ((N * sum - bit_num_squared) % DIV) << endl;
}
