#include <bits/stdc++.h>
int compare_smallorder(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}
int main() {
  unsigned long long i, n, a[300002] = {}, j, ans = 0;
  scanf("%lld", &n);
  for (i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  qsort(a, n, sizeof(a[0]), compare_smallorder);
  for (i = 0; i < n - 1; i++) {
    for (j = i + 1; j < n; j++) ans += (a[i] ^ a[j]) % 1000000007;
    ans %= 1000000007;
  }
  printf("%lld", ans);
  return 0;
}
