#include <bits/stdc++.h>
using namespace std;
int N;
vector<long long> A;
vector<long long> BC;
long long sum = 0;
long long ML = 0;
long long MaxV(void) {
  long long M = 0;
  for (int i = 0; i < A.size(); i++) M = max(A[i], M);
  return M;
}
long long LenN(long long n) {
  if (n < 2)
    return 1;
  else
    return LenN(n / 2) + 1;
}
void AddBit(long long n) {
  for (int i = 0; i < ML; i++) {
    if (n & (1 << i)) BC[i]++;
  }
}
int main() {
  cin >> N;
  long long a;
  for (int i = 0; i < N; i++) {
    cin >> a;
    A.push_back(a);
  }
  BC.resize(ML = LenN(MaxV()));
  for (int i = 0; i < A.size(); i++) AddBit(A[i]);
  for (int i = 0; i < BC.size(); i++) {
    long long mul = (1 << i);
    sum = ((((mul % 1000000007) * ((BC[i] * (N - BC[i])) % 1000000007)) %
            1000000007) +
           sum) %
          1000000007;
  }
  cout << sum << endl;
  return 0;
}
