#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
struct edge {
  int from, to;
  ll cost;
};
ll A[303030];
int cnt[303030][70];
ll sq[70];
int N;
int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    for (int k = 0; k < 61; ++k) {
      if (A[i] & (1LL << k)) cnt[i + 1][k]++;
      cnt[i + 1][k] += cnt[i][k];
    }
  }
  sq[0] = 1;
  for (int i = 0; i < 62; ++i) sq[i + 1] = sq[i] * 2;
  ll res = 0;
  for (int i = 0; i < N; ++i) {
    for (int k = 0; k < 61; ++k) {
      if (A[i] & (1LL << k)) {
        res = (res +
               (sq[k] * abs((cnt[N][k] - cnt[i + 1][k] - (N - i - 1))) % MOD)) %
              MOD;
      } else {
        res = (res + (sq[k] * (cnt[N][k] - cnt[i + 1][k]) % MOD)) % MOD;
      }
    }
  }
  cout << res << endl;
  return 0;
}
