#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
long long cnt[60][2], a[300005];
signed main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  ;
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    if (i) {
      for (long long j = 0; j < 60; j++) {
        for (long long k = 0; k < 2; k++) {
          ans += cnt[j][k] * (((a[i] >> j & 1) ^ k) << j) % M;
        }
      }
    }
    for (long long j = 0; j < 60; j++) cnt[j][a[i] >> j & 1]++;
  }
  cout << ans % M << endl;
}
