#include <bits/stdc++.h>
using namespace std;
long long n, a[300005];
long long ff() {
  long long ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
      ans += a[i] ^ a[j];
      ans %= 1000000007;
    }
  return ans % 1000000007;
}
long long F() {
  long long sum = 0;
  for (long long i = 0; i < 64; i++) {
    long long zc = 0, oc = 0;
    long long ss = 0;
    for (long long j = 0; j < n; j++) {
      if (a[j] % 2 == 0)
        zc++;
      else
        oc++;
      a[j] /= 2;
    }
    ss = ((oc) * (zc) * ((1 << i)));
    ss += 1000000007;
    ss %= 1000000007;
    sum += (ss % 1000000007);
    sum += 1000000007;
    sum %= 1000000007;
  }
  return sum % 1000000007;
}
int main() {
  cin >> n;
  for (int k = 0; k < n; k++) cin >> a[k];
  if (n < 5000)
    cout << ff() % 1000000007;
  else
    cout << F() % 1000000007;
  return 0;
}
