#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  long long int arr[n];
  for (long long int i = 0; i < n; ++i) cin >> arr[i];
  long long int b[32];
  for (long long int i = 0; i < 32; ++i) b[i] = 0;
  for (long long int i = 0; i < n; ++i) {
    long long int t = arr[i];
    long long int z = 0;
    long long int p = t;
    while (p) {
      if (t & (1 << z)) b[z]++;
      z++;
      p = p / 2;
    }
  }
  long long int ans = 0;
  for (long long int i = 0; i < n; ++i) {
    long long int v = 0;
    for (long long int j = 0; j < 32; ++j) {
      if (b[j] > 0) {
        v += (1 << j);
        b[j]--;
      }
    }
    if (v > 0) ans += pow(v, 2);
  }
  cout << ans;
}
