#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double PI = acos(-1.0);
int n;
int main() {
  vector<int> count(60, 0);
  cin >> n;
  int ans = 0;
  for (int i = (0); i < (n); i++) {
    int a;
    cin >> a;
    for (int j = (0); j < (60); j++) {
      count[j] += a % 2;
      a /= 2;
    }
  }
  long long x = 1;
  for (int i = (0); i < (60); i++) {
    ans += count[i] * (n - count[i]) * x;
    x *= 2;
  }
  cout << ans << endl;
}
