#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long bit[65] = {0};
  long long n, ans = 0;
  cin >> n;
  long long data[n + 5];
  for (long long i = 1; i <= n; i++) {
    cin >> data[i];
    long long x = data[i];
    for (long long j = 0; j <= 60; j++) {
      if ((1LL << j) & x) {
        bit[j]++;
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    long long x = data[i];
    for (long long j = 0; j <= 60; j++) {
      if ((1LL << j) & x) {
        bit[j]--;
        long long zero = n - i - bit[j];
        ans = (ans % mod + zero * (1LL << j) % mod) % mod;
      } else {
        long long zero = bit[j];
        ans = (ans % mod + zero * (1LL << j) % mod) % mod;
      }
    }
  }
  cout << ans << '\n';
}
