#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int N = 3 * 1e5 + 7;
long long n;
long long data[65][2], a[N], maxx = -1, ans = 0;
long long maxn(long long a, long long b) {
  if (a >= b) return a;
  return b;
}
void in() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    maxx = maxn(maxx, a[i]);
  }
  for (int i = 1; i <= n; i++) {
    long long cnt = 1, o = 0;
    while (cnt <= maxx) {
      if ((a[i] ^ cnt) > a[i])
        data[o][0]++;
      else
        data[o][1]++;
      cnt *= 2;
      o++;
    }
  }
  long long cnt = 1, o = 0;
  while (cnt <= maxx) {
    ans += cnt % MOD * data[o][0] * data[o][1] % MOD;
    ans %= MOD;
    cnt *= 2;
    o++;
  }
  cout << ans % MOD;
}
int main() { in(); }
