#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> data(n);
  for (int i = 0; i < data.size(); ++i) {
    cin >> data[i];
  }
  sort(data.begin(), data.end());
  int multiply = 1;
  long long res = 0;
  for (int i = 0; i < data.size(); ++i) {
    if (i + 1 < data.size() && data[i] == data[i + 1]) {
      ++multiply;
      continue;
    }
    for (int j = i + 1; j < data.size(); ++j) {
      long long cur = data[i] ^ data[j];
      if (multiply > 1) {
        cur %= 1000000000 + 7;
        cur *= multiply;
      }
      res += cur;
      res %= 1000000000 + 7;
    }
    multiply = 1;
  }
  cout << res << endl;
  return 0;
}
