#include <bits/stdc++.h>
using namespace std;
long long N, M, H, W, K, Q, A, B;
string S;
const long long MOD = (1e+9) + 7;
const long long INF = 1LL << 60;
int main() {
  cin >> N;
  vector<long long> a(N), sum(N + 1, 0);
  for (int i = 0; i < N; i++) cin >> a[i], sum[i + 1] = sum[i] + a[i];
  long long minus = 0;
  for (int j = 0; j < 60; j++) {
    long long num = 0;
    for (int i = 0; i < N; i++) num += (a[i] >> j) & 1;
    long long kumi = max(0LL, (num * (num - 1) / 2) % MOD);
    (minus += (kumi * (1LL << (j + 1))) % MOD) %= MOD;
  }
  long long ans = MOD - minus;
  for (int i = 0; i < N; i++) {
    (ans += ((N - 1) * a[i]) % MOD) %= MOD;
  }
  cout << ans << endl;
}
