#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long arr[32] = {0};
  long long given[n];
  for (long long i = 0; i < n; i++) cin >> given[i];
  for (long long i = 0; i < 32; i++) {
    for (long long j = 0; j < n; j++) {
      if (given[j] & 1) arr[i]++;
      if (given[j] > 0) given[j] >>= 1;
    }
  }
  long long ans = 0;
  for (long long i = 0; i < 26; i++) {
    ans += (n - arr[i]) * arr[i] * pow(2, i);
  }
  cout << ans << endl;
}
