#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 5005;
long long mult(long long a, long long b) {
  if (a == 0 || b == 0) {
    return 0;
  } else {
    if (a % 2 == 1) {
      return (b + mult(a - 1, b)) % MOD;
    } else
      return mult(a / 2, b) * 2 % MOD;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ans = 0;
  vector<long long> cnt(64, 0);
  for (int i = n - 1; i >= 0; i--) {
    for (int bit = 0; bit < 61; bit++) {
      long long same = (1LL << bit);
      if (a[i] & (1LL << bit)) {
        cnt[bit]++;
        ans += mult((n - i - cnt[bit]), same);
        ans %= MOD;
      } else {
        ans += mult(cnt[bit], same);
        ans %= MOD;
      }
    }
  }
  cout << ans << endl;
}
