#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long IINF = 1e18;
const double EPS = 1e-8;
const double pi = acos(-1);
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  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>> cnt(N + 1, vector<long long>(61, 0));
  for (long long i = 0; i < N; ++i) {
    for (long long j = 0; j < 61; ++j) {
      cnt[i + 1][j] = cnt[i][j];
      if (A[i] & (1LL << j)) ++cnt[i + 1][j];
    }
  }
  long long ans = 0;
  for (long long i = 0; i < N; ++i) {
    for (long long j = 0; j < 61; ++j) {
      if (A[i] & (1LL << j))
        ans = (ans + (i - cnt[i][j]) * (1LL << j) % MOD) % MOD;
      else
        ans = (ans + cnt[i][j] * (1LL << j) % MOD) % MOD;
    }
  }
  cout << ans << endl;
}
