#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
const int mod = 1e9 + 7;
long long a[N], p[N];
long long sum[N];
int n;
int main() {
  p[0] = 1;
  for (int i = 1; i <= 100; i++) p[i] = (p[i - 1] * 2) % mod;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  long long ans = 0;
  for (int i = 0; i <= 60; i++) {
    for (int j = 1; j <= n; j++) {
      if ((a[j] >> i) & 1)
        sum[j] = sum[j - 1] + 1;
      else
        sum[j] = sum[j - 1];
    }
    long long cnt = 0;
    for (int j = 1; j < n; j++) {
      if ((a[j] >> i) & 1) {
        cnt += (n - j - (sum[n] - sum[j]));
      } else {
        cnt += (sum[n] - sum[j]);
      }
    }
    ans = (ans + (1ll * cnt * p[i] % mod)) % mod;
  }
  printf("%lld\n", ans);
  return 0;
}
