#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 2e9 + 13;
const int mINF = -2e9 - 13;
const double PI = 3.14159265358979;
const double EPS = 1e-9;
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  vector<long long int> two(60);
  two[0] = 1;
  for (long long int i = 1; i < 60; ++i) two[i] = two[i - 1] * 2;
  int N;
  cin >> N;
  vector<long long int> A(N);
  for (auto &x : A) cin >> x;
  vector<long long int> B(60);
  long long int ans = 0;
  for (long long int i = 0; i < N; ++i) {
    long long int s = A[i];
    for (long long int j = 0; j < 60; ++j) {
      B[j] += s % 2;
      s >>= 1;
    }
  }
  for (long long int i = 0; i < N - 1; ++i) {
    long long int s = A[i];
    for (long long int j = 0; j < 60; ++j) {
      B[j] -= s % 2;
      s >>= 1;
    }
    s = A[i];
    long long int kalan = N - 1 - i;
    for (int j = 0; j < 60; ++j) {
      if (s % 2) {
        ans += (two[j] * (kalan - B[j])) % MOD;
        ans %= MOD;
      } else {
        ans += (two[j] * B[j]) % MOD;
        ans %= MOD;
      }
      s >>= 1;
    }
  }
  ans %= MOD;
  cout << ans << endl;
  return 0;
}
