#include <bits/stdc++.h>
using namespace std;
long long A[300000];
long long A_bits[300000][60];
long long cum_sum_A[300000];
long long cum_sum_bits[300000][60];
const long long MOD = 1000000007;
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    for (int j = 0; j < 60; j++) {
      if (((A[i] >> j) & 1) == 1) {
        A_bits[i][j] = 1;
      }
    }
  }
  cum_sum_A[0] = A[0];
  for (int j = 0; j < 60; j++) {
    cum_sum_bits[0][j] = A_bits[0][j];
  }
  for (int i = 1; i < N; i++) {
    cum_sum_A[i] = (A[i] + cum_sum_A[i - 1]) % MOD;
    for (int j = 0; j < 60; j++) {
      cum_sum_bits[i][j] = A_bits[i][j] + cum_sum_bits[i - 1][j];
    }
  }
  long long ans = 0;
  for (long long i = 0; i < N; i++) {
    long long tmp = cum_sum_A[N - 1] - cum_sum_A[i];
    for (long long j = 0; j < 60; j++) {
      if (((A[i] >> j) & 1) == 1) {
        long long pl =
            (((1 << j) % MOD) *
             (N - 1 - i - (cum_sum_bits[N - 1][j] - cum_sum_bits[i][j]))) %
            MOD;
        long long mi = (((1 << j) % MOD) *
                        ((cum_sum_bits[N - 1][j] - cum_sum_bits[i][j]))) %
                       MOD;
        tmp = ((tmp - mi) % MOD + MOD) % MOD;
        tmp = ((tmp + pl) % MOD + MOD) % MOD;
      }
    }
    ans = (ans + tmp) % MOD;
  }
  cout << ans << endl;
  return 0;
}
