#include <bits/stdc++.h>
using namespace std;
int main() {
  const int64_t MOD = 1e9 + 7;
  int N;
  cin >> N;
  vector<int64_t> a(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  int n = 61;
  vector<int64_t> b(n);
  b[0] = 1;
  for (int i = 1; i < n; ++i) {
    b[i] = (b[i - 1] * 2) % MOD;
  }
  int64_t ans = 0;
  vector<vector<int64_t>> memo(n, vector<int64_t>(2, 0));
  for (int i = 0; i < N; ++i) {
    int64_t tmp = a[i];
    for (int j = 0; j < n; ++j) {
      if ((tmp >> j) & 1) {
        (ans += memo[j][0] * b[j]) % MOD;
        (memo[j][1] += 1) % MOD;
      } else {
        (ans += memo[j][1] * b[j]) % MOD;
        (memo[j][0] += 1) % MOD;
      }
    }
  }
  cout << ans % MOD << endl;
  return 0;
}
