#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18 + 5;
const long long nax = 3e5 + 4;
long long arr[nax];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> arr[i];
  long long ans = 0;
  for (long long i = 1; i < n; i++) {
    for (long long j = i + 1; j <= n; j++) {
      ans += (arr[i] ^ arr[j]);
    }
  }
  cout << ans << '\n';
  return 0;
}
