#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  char ch = getchar();
  long long nega = 1;
  while (!isdigit(ch)) {
    if (ch == '-') nega = -1;
    ch = getchar();
  }
  long long ans = 0;
  while (isdigit(ch)) {
    ans = ans * 10 + ch - 48;
    ch = getchar();
  }
  if (nega == -1) return -ans;
  return ans;
}
long long a[300005];
long long b[300005];
long long qpow(long long u, long long v) {
  long long ans = 1;
  while (v) {
    if (v & 1) ans = ans * u % 1000000007;
    u = u * u % 1000000007;
    v >>= 1;
  }
  return ans;
}
signed main() {
  long long n = read();
  for (long long i = 1; i <= n; i++) a[i] = read();
  long long res = 0;
  for (long long i = 0; i < 60; i++) {
    for (long long j = 1; j <= n; j++) b[j] = (a[j] >> i) & 1;
    long long s0 = 0, s1 = 0;
    long long ans = 0;
    for (long long j = 1; j <= n; j++) {
      if (b[j] == 0)
        s0++, ans += s1;
      else
        s1++, ans += s0;
    }
    res = (res + ans * qpow(2, i)) % 1000000007;
  }
  cout << res << endl;
  return 0;
}
