#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int n;
long long arr[N], a[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> arr[i];
  for (int bit = 30; bit >= 0; --bit) {
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
      if (arr[i] & (1LL << bit)) ++cnt;
    }
    for (int i = 1; i <= cnt; ++i) a[i] |= (1LL << bit);
  }
  long long ans = 0;
  for (int i = 1; i <= n; ++i) ans += (a[i] * a[i]);
  cout << ans << '\n';
}
