#include <bits/stdc++.h>
using namespace std;
int cnt[22];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    for (int j = 0; j < 22; ++j) {
      cnt[j] += ((x >> j) & 1) == 1;
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    int x = 0;
    for (int j = 0; j < 22; ++j) {
      if (cnt[j] > 0) {
        x |= 1 << j;
        --cnt[j];
      }
    }
    ans += 1LL * x * x;
  }
  printf("%lld", ans);
  return 0;
}
