#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 7;
const long long mod = 1e9 + 7;
long long a[maxn];
long long p[64] = {1};
long long b[64] = {0};
int main(void) {
  int n;
  for (int i = 1; i < 63; ++i) {
    p[i] = p[i - 1] * 2ll;
  }
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  long long ans = 0;
  for (int j = n - 1; j >= 0; --j) {
    long long x = a[j];
    for (int i = 0; i < 63; ++i) {
      if ((x & 1) == 0)
        ans = (ans + (b[i] * p[i]) % mod) % mod;
      else
        ans = (ans + ((n - 1 - j - b[i]) * p[i]) % mod) % mod, b[i]++;
      x >>= 1;
    }
  }
  cout << ans << endl;
}
