#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
const int MAXB = 100 + 5;
const int HA = 1e9 + 7;
int n, occ[MAXB], ou;
long long a[MAXN], ans, pw[MAXB];
void add(long long x, int f) {
  int p = -1;
  for (; x; x >>= 1) occ[++p] += (x & 1) * f;
}
void solve(long long x) {
  long long ret = 0;
  for (int i = 0; i <= 60; i++) {
    int ch = (x >> i) & 1;
    if (ch == 0)
      ret = (ret + (occ[i] * pw[i])) % HA;
    else
      ret = (ret + (n - 1 - occ[i]) * pw[i]) % HA;
  }
  ans = (ans + ret) % HA;
}
int main() {
  pw[0] = 1;
  for (int i = 1; i <= 61; i++) pw[i] = (pw[i - 1] * 2) % HA;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    add(a[i], 1);
  }
  for (int i = 1; i <= n; i++) {
    add(a[i], -1);
    solve(a[i]);
    add(a[i], 1);
  }
  ou = ans / 2;
  cout << ou;
  return 0;
}
