#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
template <typename T>
T modMul(T a, T b, T m) {
  T x = 0, y = a % m;
  while (b > 0) {
    if (b % 2 == 1) x = (x + y) % m;
    y = (y * 2) % m;
    b /= 2;
  }
  return x % m;
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin.exceptions(cin.failbit);
  int n;
  cin >> n;
  long long a[n], ones[n + 1][60], zeroes[n + 1][60];
  memset(ones, 0, sizeof ones);
  memset(zeroes, 0, sizeof zeroes);
  for (int i = 0; i < (n); ++i) {
    cin >> a[i];
    for (int j = 0; j < (60); ++j) {
      ones[i + 1][j] = ones[i][j] + ((a[i] & (1LL << j)) > 0);
      zeroes[i + 1][j] = zeroes[i][j] + ((a[i] & (1LL << j)) == 0);
    }
  }
  long long ans = 0;
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (60); ++j) {
      if (a[i] & (1 << j))
        ans += zeroes[n][j] - zeroes[i][j]
                   ? modMul(zeroes[n][j] - zeroes[i][j], 1LL << j, mod)
                   : 0;
      else
        ans += ones[n][j] - ones[i][j]
                   ? modMul(ones[n][j] - ones[i][j], 1LL << j, mod)
                   : 0;
      ans %= mod;
    }
  }
  cout << ans << '\n';
  return 0;
}
