#include <bits/stdc++.h>
using namespace std;
const long long int ll_MAX = 1e18 + 5;
const long long int MOD = 1e9 + 7;
long long int fast_expo(long long int x, long long int p) {
  if (p == 0)
    return 1;
  else if (p % 2 == 0) {
    long long int t = fast_expo(x, p / 2) % MOD;
    return (t * t) % MOD;
  } else
    return (x * (fast_expo(x, p - 1)) % MOD) % MOD;
}
long long int gcd(long long int a, long long int b) {
  if (a == 0 || b == 0)
    return a + b;
  else
    return gcd(b % a, a);
}
int main() {
  long long int t_c;
  t_c = 1;
  for (long long int t_i = 0; t_i < t_c; ++t_i) {
    long long int n;
    cin >> n;
    long long int arr[n];
    for (auto &i : arr) cin >> i;
    long long int cnt[21]{};
    for (auto i : arr) {
      for (long long int j = 0; j < 21; ++j)
        if (i & (1 << j)) cnt[j]++;
    }
    long long int ans = 0;
    for (long long int i = 0; i < n; ++i) {
      long long int val = 0;
      for (long long int j = 0; j < 21; ++j) {
        if (cnt[j] > 0) {
          val += (1 << j);
          cnt[j]--;
        }
      }
      ans += val * val;
    }
    cout << ans;
  }
  return 0;
}
