#include <bits/stdc++.h>
#pragma gcc optimize("Ofast")
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  vector<int> cnt(25);
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    for (int j = 0; (1 << j) <= a; ++j) {
      cnt[j] += !!((1 << j) & a);
    }
  }
  ll ans = 0;
  int xd = 1;
  while (xd) {
    xd = 0;
    int tmp = 0;
    for (int j = 20; ~j; --j) {
      if (cnt[j]) {
        xd = 1;
        --cnt[j];
        tmp |= (1 << j);
      }
    }
    ans += 1LL * tmp * tmp;
  }
  cout << ans << '\n';
}
