#include <bits/stdc++.h>
using namespace std;
const int maxn = 300000;
int main() {
  int n;
  int64_t mod = 1e9 + 7;
  int64_t ans = 0;
  int64_t a[maxn];
  cin >> n;
  for (long long int i = 0; i < n; i++) cin >> a[i];
  int64_t b = 1;
  for (long long int i = 0; i < 60; i++) {
    int64_t c = b;
    b = b * 2;
    int64_t A = 0, B = 0;
    for (long long int j = 0; j < n; j++) {
      int64_t t = a[j] % b;
      if (t < 0) t += mod;
      if (c <= t) A++;
    }
    B = n - A;
    int64_t add = A * B % mod;
    if (add < 0) add += mod;
    add = add * c % mod;
    if (add < 0) add += mod;
    ans = (ans + add) % mod;
    if (ans < 0) ans += mod;
  }
  cout << ans << endl;
  return 0;
}
