#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long llinf = (1LL << 62);
const int inf = (1 << 30);
const int nmax = 3e5 + 50;
const long long mod = 1e9 + 7;
using namespace std;
int n, i, j, nr[100];
long long a[nmax], rs;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cerr.tie(0);
  cout.tie(0);
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    for (j = 0; j < 60; j++)
      if (a[i] & (1LL << j)) nr[j]++;
  }
  for (i = 1; i < n; i++) {
    for (j = 0; j < 60; j++) {
      if (a[i] & (1LL << j)) nr[j]--;
      if (a[i] & (1LL << j)) {
        rs += 1LL * (n - i - nr[j]) * (1LL << j) % mod;
        rs %= mod;
      } else {
        rs += 1LL * nr[j] * (1LL << j) % mod;
        rs %= mod;
      }
    }
  }
  cout << rs << endl;
  return 0;
}
