#include <bits/stdc++.h>
using namespace std;
int fact[300 * 1000 + 5], fact_inv[300 * 1000 + 5];
const int mod = 1000 * 1000 * 1000 + 7;
using ll = long long;
int mul(ll a, ll b) {
  int ans = (1LL * a * b) % mod;
  while (ans >= mod) ans -= mod;
  while (ans < 0) ans += mod;
  return ans;
}
int mpow(int a, int n) {
  if (n == 0) return 1;
  int x = mpow(a, n / 2);
  x = mul(x, x);
  if (n % 2) x = mul(x, a);
  return x;
}
int binomial(int n, int k) {
  return mul(fact[n], mul(fact_inv[n - k], fact_inv[k]));
}
void add_self(ll& a, ll b) {
  a += b;
  while (a >= mod) a -= mod;
}
void sub_self(ll& a, ll b) {
  a -= b;
  while (a < 0) a += mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  fact[0] = fact_inv[0] = 1;
  for (int i = 1; i < 300 * 1000 + 5; i++) {
    fact[i] = mul(fact[i - 1], i);
    fact_inv[i] = mpow(fact[i], mod - 2);
  }
  int n;
  cin >> n;
  vector<ll> arr(n);
  for (ll& x : arr) cin >> x;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    add_self(ans, mul(n - 1, arr[i]));
  }
  for (int b = 0; b < 60; b++) {
    int k = 0;
    for (int i = 0; i < n; i++) {
      k += arr[i] >> b & 1;
    }
    if (k > 1) {
      sub_self(ans, mul(1LL << (b + 1), binomial(k, 2)));
    }
  }
  cout << ans << endl;
}
