#include <bits/stdc++.h>
using namespace std;
static void A() {
  int T;
  cin >> T;
  for (int i = 0; i < T; i++) {
    int a, b, n, res = 0;
    cin >> a >> b >> n;
    while (max(a, b) <= n) {
      if (a > b) {
        b += a;
      } else if (a <= b) {
        a += b;
      }
      res++;
    }
    cout << res << endl;
  }
}
static void B() {
  long long k;
  cin >> k;
  multiset<long long> c;
  for (int i = 0; i < 10; i++) c.insert(1);
  while (true) {
    long long prod = 1;
    for (auto it = c.begin(); it != c.end(); ++it) {
      prod *= *it;
    }
    if (prod >= k) break;
    auto item = *c.begin();
    c.erase(c.begin());
    c.insert(item + 1);
  }
  vector<char> counts;
  counts.push_back('c');
  counts.push_back('o');
  counts.push_back('d');
  counts.push_back('e');
  counts.push_back('f');
  counts.push_back('o');
  counts.push_back('r');
  counts.push_back('c');
  counts.push_back('e');
  counts.push_back('s');
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < *c.begin(); j++) {
      cout << counts[i];
    }
    c.erase(c.begin());
  }
  cout << endl;
}
static void D() {
  int n;
  cin >> n;
  vector<int> cnt(20, 0);
  for (int i = 0; i < n; i++) {
    int num;
    cin >> num;
    int j = 0;
    while (num > 0) {
      if ((num & 1) > 0) cnt[j]++;
      num >>= 1;
      j++;
    }
  }
  long long res = 0;
  bool cont = false;
  while (true) {
    int num = 0;
    cont = false;
    for (int i = 0; i < 20; i++) {
      if (cnt[i] > 0) {
        num |= (1 << i);
        cnt[i]--;
        if (cnt[i] > 0) cont = true;
      }
    }
    res += (long long)num * num;
    if (!cont) break;
  }
  cout << res << endl;
}
int main() {
  ios::sync_with_stdio(false);
  ;
  D();
  return 0;
}
