#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const int INF = int(2e9);
const long long LINF = long long(2e9) * long long(2e9);
template <class T, class C>
void chmax(T& a, C b) {
  a > b ?: a = b;
}
template <class T, class C>
void chmin(T& a, C b) {
  a < b ?: a = b;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  int bit_num = 61;
  vector<int> bit_on_num(bit_num, 0);
  for (int i = 0; i < bit_num; i++) {
    for (int j = 0; j < N; j++) {
      if (((A[j] >> i) & 0x01) != 0) bit_on_num[i]++;
    }
  }
  long long ans = 0;
  vector<long long> ans_bit_on_num(bit_num, 0);
  for (int i = 0; i < N; i++) {
    for (int b = 0; b < bit_num; b++) {
      bool bit_on = false;
      if (((A[i] >> b) & 0x01) != 0) {
        bit_on = true;
      }
      if (bit_on == true) {
        bit_on_num[b]--;
        ans_bit_on_num[b] += (N - 1 - i) - bit_on_num[b];
      } else {
        ans_bit_on_num[b] += bit_on_num[b];
      }
    }
  }
  long long m = 1000000007;
  for (int b = 0; b < bit_num; b++) {
    ans += ((1LL << b) * ans_bit_on_num[b]);
    ans %= m;
  }
  cout << ans << endl;
  return 0;
}
