#include <bits/stdc++.h>
using namespace std;
const int MAX_SIZE = 100;
int dp[MAX_SIZE], n;
int main() {
  scanf("%d", &n);
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= n; i++) {
    int t;
    scanf("%d", &t);
    int cnt = 0;
    while (t) {
      cnt++;
      if (t % 2) dp[cnt]++;
      t /= 2;
    }
  }
  int ans = 0;
  for (int i = 0; i < 31; i++) ans += (1 << i) * dp[i + 1] * (n - dp[i + 1]);
  printf("%d\n", ans);
  return 0;
}
