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