#include <bits/stdc++.h>
const int INF = (int)1e9 + 10;
const long long MOD = (long long)1e9 + 7;
const long long LINF = (long long)4e18 + 20;
const long double PI = acos(-1.0);
const double EPS = 1e-9;
using namespace ::std;
void chmax(long long& a, long long b) { a = max(a, b); }
void solve() {
  int N;
  cin >> N;
  vector<long long> A(N);
  vector<vector<int>> B(N, vector<int>(64, 0));
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    long long temp = A[i];
    for (int j = 0; j < 64; ++j) {
      if (temp & 1) {
        B[i][j] = 1;
      }
      temp /= 2;
    }
  }
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 64; ++j) {
      if (i > 0) {
        B[i][j] += B[i - 1][j];
      }
    }
  }
  long long sum = 0;
  for (int i = 0; i < N - 1; ++i) {
    int ter = A[i];
    long long base = 1;
    for (int j = 0; j < 64; ++j) {
      if (ter & 1) {
        long long res = N - (i + 1) - (B[N - 1][j] - B[i][j]);
        sum += (base * res) % MOD;
        sum %= MOD;
      } else {
        long long res = (B[N - 1][j] - B[i][j]);
        sum += (base * res) % MOD;
        sum %= MOD;
      }
      ter = ter / 2;
      base = (base * 2) % MOD;
    }
  }
  cout << sum << endl;
}
signed main(void) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed;
  cout << setprecision(16);
  solve();
}
