#include <bits/stdc++.h>
using namespace std;
vector<long long int> vec;
vector<vector<long long int> > vec2;
long long int INF = 1145141919454519;
long long int mod = 1e9 + 7;
long long int fast_pow(long long int a, long long int n) {
  if (n == 0) return 1;
  if (n % 2 == 1) {
    return a * fast_pow(a, n - 1) % mod;
  } else {
    return fast_pow(a * a % mod, n / 2) % mod;
  }
}
int main() {
  long long int N;
  cin >> N;
  for (long long int i = 0; i < N; i++) {
    long long int t;
    cin >> t;
    vec.push_back(t);
  }
  vector<vector<long long int> > zero_sum(N + 19, vector<long long int>(61, 0));
  vector<vector<long long int> > one_sum(N + 19, vector<long long int>(61, 0));
  for (long long int i = 0; i < N; i++) {
    for (long long int j = 0; j <= 60; j++) {
      if ((vec[i] >> j) & 1 == 1) {
        zero_sum[i + 1][j] = zero_sum[i][j];
        one_sum[i + 1][j] = one_sum[i][j] + 1;
      } else {
        one_sum[i + 1][j] = one_sum[i][j];
        zero_sum[i + 1][j] = zero_sum[i][j] + 1;
      }
    }
  }
  long long int ans = 0;
  for (long long int i = 0; i < N; i++) {
    for (long long int j = 0; j <= 60; j++) {
      if ((vec[i] >> j) & 1 == 1) {
        long long int num = zero_sum[N][j] - zero_sum[i + 1][j];
        ans += fast_pow(2, j) * num % mod;
        ans %= mod;
      } else {
        long long int num = one_sum[N][j] - one_sum[i + 1][j];
        ans += fast_pow(2, j) * num % mod;
        ans %= mod;
      }
    }
  }
  cout << ans << endl;
}
