#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
template <typename T>
T modpow(T x, T n, T m) {
  if (n == 0) return 1;
  T resp = modpow(x * x % m, n / 2, mod);
  if (n & 1) resp = resp * x % m;
  return resp;
}
int main() {
  int n;
  cin >> n;
  const long long m = 61;
  vector<long long> a(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  vector<vector<long long> > d(n, vector<long long>(m + 1, 0));
  vector<vector<long long> > dd(n, vector<long long>(m + 1, 0));
  for (int i = 0; i < (n); i++) {
    for (long long j = 0; j <= m; j++) {
      if (a[i] >> j & 1)
        d[i][j]++;
      else
        dd[i][j]++;
      if (i != n - 1) d[i + 1][j] += d[i][j], dd[i + 1][j] += dd[i][j];
    }
  }
  long long ans = 0;
  for (int i = 0; i < (n); i++) {
    for (long long j = 0; j <= m; j++) {
      if (a[i] >> j & 1) {
        ans += (dd[n - 1][j] - dd[i][j]) *
               modpow((long long)2, (long long)(j), mod) % mod;
        ans %= mod;
      } else {
        ans += (d[n - 1][j] - d[i][j]) *
               modpow((long long)2, (long long)(j), mod) % mod;
        ans %= mod;
      }
    }
  }
  cout << (ans %= mod) << endl;
  return 0;
}
