#include <bits/stdc++.h>
using namespace std;
int myXOR(int a, int b) {
  int res = 0;
  for (int k = 31; k >= 0; k--) {
    bool b1 = a & (1 << k);
    bool b2 = b & (1 << k);
    bool xoredBit = (b1 & b2) ? 0 : (b1 | b2);
    res <<= 1;
    res |= xoredBit;
  }
  return res;
}
int main() {
  int N, A[300000], i, j, x, y, sum = 0;
  cin >> N;
  for (i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (i = 0; i < N - 1; i++) {
    for (j = i + 1; j < N; j++) {
      x = A[i];
      y = A[j];
      myXOR(x, y);
      sum = sum + myXOR(x, y);
    }
  }
  cout << sum << endl;
  return 0;
}
