#include <bits/stdc++.h>
#define ll long long
using namespace std;


int main()
{
	int n;
	cin>>n;
	ll arr[n+1];
	ll sum = 0;
	for(int i = 0;i<n;i++)
		cin>>arr[i];
	for(i = 1;i<n;i++)
	{
		for(int j = i+1;j<=n;j++)
		{
			sum = sum + arr[i]^arr[j];
		}
	}
	cout<<sum<<'\n';
}