#include <bits/stdc++.h>
using namespace std;
int a[300001] = {0};
int n;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    long long int k;
    cin >> k;
    int j = 0;
    while (k != 0) {
      a[j] = a[j] + k % 2;
      j++;
      k /= 2;
    }
  }
  long long int max = 0;
  for (int i = 0; i <= 300000; i++) {
    int t = 1;
    for (int j = 1; j <= i; j++) t *= 2;
    max += (n - a[i]) * a[i] * t;
  }
  cout << max;
}
