#include <bits/stdc++.h>
using namespace std;
int pairORSum(unsigned long long arr[], unsigned long long n) {
  unsigned long long ans = 0;
  for (unsigned long long i = 0; i < n; i++)
    for (unsigned long long j = i + 1; j < n; j++) ans += arr[i] ^ arr[j];
  return ans;
}
int main() {
  unsigned long long t;
  cin >> t;
  unsigned long long arr[t];
  for (unsigned long long i = 0; i < t; i++) {
    cin >> arr[i];
  }
  unsigned long long n = sizeof(arr) / sizeof(arr[0]);
  cout << pairORSum(arr, n) << endl;
  return 0;
}
