#include <bits/stdc++.h>
using namespace std;
long long N;
const long long mod = 1000000007;
int main() {
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  long long result = 0;
  for (long long b = 0; b < 60; b++) {
    long long bb = (long long)1 << b;
    vector<int> bitacc(N + 1);
    int acc = 0;
    for (int i = 0; i < N; i++) {
      bitacc[i] = acc;
      if (A[i] & bb) acc++;
    }
    bitacc[N] = acc;
    int sum = 0;
    for (int i = 0; i < N - 1; i++) {
      if (A[i] & bb) {
        sum += (N - 1 - i) - (bitacc[N] - bitacc[i + 1]);
      } else {
        sum += bitacc[N] - bitacc[i + 1];
      }
    }
    result += (bb % mod) * sum;
    result %= mod;
  }
  cout << result << endl;
  return 0;
}
