#include <bits/stdc++.h>
using namespace std;
int GetDigit(int num) {
  int digit = 0;
  while (num != 0) {
    num /= 10;
    digit++;
  }
  return (digit);
}
string to_binary(int input) {
  string output;
  int length = GetDigit(input);
  while (input > 0) {
    ostringstream oss;
    oss << input % 2;
    output = oss.str() + output;
    input = input / 2;
  }
  return (output);
}
int to_decimal(string input) {
  int output = 0;
  for (int i = 0; i < input.size(); i++) {
    int tmp_int = input[input.size() - 1 - i] - '0';
    output += pow(2.0, i * 1.0) * tmp_int;
  }
  return (output);
}
int XOR(int V1, int V2) {
  string S1 = to_binary(V1);
  int S1_len = S1.size();
  string S2 = to_binary(V2);
  int S2_len = S2.size();
  string output;
  if (S1_len < S2_len) {
    while (S1_len != S2_len) {
      S1 = "0" + S1;
      S1_len = S1.size();
    }
  } else {
    while (S1_len != S2_len) {
      S2 = "0" + S2;
      S2_len = S2.size();
    }
  }
  for (int i = (S1_len - 1); i >= 0; i--) {
    ostringstream oss;
    oss << (S1[i] != S2[i]);
    output = oss.str() + output;
  }
  return (to_decimal(output));
}
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int output = 0;
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      output += XOR(A[i], A[j]);
    }
  }
  cout << output << endl;
  return (0);
}
