#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 1;
const long long LLINF = 1e17 + 1;
const int DX[9] = {0, 0, 1, -1, 1, 1, -1, -1, 0};
const int DY[9] = {1, -1, 0, 0, 1, -1, 1, -1, 0};
const long long MOD = 1e9 + 7;
const double PI = 3.14159265358979323846264338327950288;
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  long long N;
  cin >> N;
  vector<long long> A(N);
  for (long long i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<vector<long long>> bits(N);
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < 60; j++) {
      bits[i].emplace_back((A[i] >> j) & 1);
    }
  }
  long long ans = 0;
  for (long long keta = 0; keta < 60; keta++) {
    long long sum = 0;
    vector<long long> ruiseki(N);
    ruiseki[0] = bits[0][keta];
    for (long long i = 1; i < N; i++) {
      ruiseki[i] = ruiseki[i - 1] + bits[i][keta];
    }
    for (long long i = 0; i < N - 1; i++) {
      long long sigma = ruiseki[N - 1] - ruiseki[i];
      if (bits[i][keta] == 0) {
        sum += sigma;
      } else {
        sum += (N - 1 - i) - (ruiseki[N - 1] - ruiseki[i]);
      }
    }
    ans += (sum * pow(2, keta));
    ans %= MOD;
  }
  cout << ans;
}
