#include <bits/stdc++.h>
const double eps = 1e-10;
const int INF = 0x3f3f3f3f;
const long long inf = 0x3f3f3f3f3f3f3f3f;
const int N = 1e6 + 5;
using namespace std;
long long t, n, m, k, cnt = 0;
long long a[65] = {0};
long long sum = 0;
long long ksm(long long a, long long b) {
  long long c = 1e18 + 7;
  long long ans = 1;
  a = a % c;
  while (b > 0) {
    if (b % 2) ans = (ans * a) % c;
    b = b / 2;
    a = (a * a) % c;
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  k = n;
  while (n--) {
    scanf("%d", &m);
    for (int i = 0; m; i++) {
      int x = m % 2;
      m /= 2;
      if (x) a[i]++;
    }
  }
  for (long long i = 0; i < 65; i++) {
    sum += a[i] * (k - a[i]) * ksm(2, i);
  }
  printf("%lld\n", sum);
  return 0;
}
