#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
void print_bits(const vector<long long>& a, int n) {
  for (auto ai : a) {
    for (int j = n; j >= 0; j--) {
      cout << ((ai >> j) & 1) << " ";
    }
    cout << endl;
  }
}
void naive(const vector<long long>& a, int n) {
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      ans += (a[i] ^ a[j]) % mod;
      ans %= mod;
    }
  }
  cout << ans << endl;
}
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  long long ans = 0;
  long long xsum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    xsum ^= a[i];
  }
  sort(a.rbegin(), a.rend());
  naive(a, n);
  return 0;
}
