#include <bits/stdc++.h>
using namespace std;
const int64_t mod = 1000000007;
const int64_t LINF = 1e13;
const int64_t LLINF = 1e18;
const int64_t ALPHABET = 26;
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}
int main() {
  int64_t N;
  cin >> N;
  vector<int64_t> a(N, 0);
  cin >> a;
  vector<int64_t> dig = vector<int64_t>(70);
  for (int64_t j = 0; j < 70; j++) {
    dig[j] = 0;
  }
  for (int i = 1; i < a.size(); i++) {
    for (int64_t j = 0; j < 62; j++) {
      if ((a[i] >> j) & 1) {
        dig[j]++;
      }
    }
  }
  for (int64_t j = 0; j < 70; j++) {
    cerr << j << "  ; dig : " << dig[j] << endl;
  }
  int64_t ans = 0;
  for (int64_t i = 0; i < N - 1; i++) {
    cerr << "a " << a[i] << endl;
    int64_t num = N - 1 - i;
    for (int64_t j = 0; j < 61; j++) {
      int64_t q = 1;
      for (int k = 0; k < j; k++) q *= 2;
      if ((a[i] >> j) & 1) {
        ans += (num - dig[j]) * q;
        ans %= mod;
      } else {
        ans += dig[j] * q;
        ans %= mod;
      }
      if (i == 1) cerr << " dig[j] :" << dig[j] << endl;
    }
    for (int64_t j = 0; j < 61; j++) {
      if (a[i + 1] >> j & 1) {
        dig[j]--;
      }
    }
  }
  cout << ans % mod << endl;
}
