#include <bits/stdc++.h>
using namespace std;
int main() {
  long n;
  long a;
  stringstream ss;
  cin >> n;
  vector<string> a_ls;
  for (int i = 0; i < n; i++) {
    cin >> a;
    ss << bitset<60>(a);
    a_ls.push_back(ss.str());
  }
  long MOD = pow(10, 9) + 7;
  vector<vector<long>> memo_ls(n + 1, vector<long>(60, 0));
  for (int i = 1; i < n + 1; i++) {
    string a = a_ls[n - i - 1];
    for (int j = 0; j < 60; j++) {
      char k = a[60 - j - 1];
      memo_ls[i][j] = memo_ls[i - 1][j] + (int)k;
    }
  }
  long res = 0;
  for (int i = 0; i < n; i++) {
    string _a = a_ls[i];
    for (int j = 0; j < 60; j++) {
      char x = _a[j];
      if (x == '0') {
        res += pow(2, j) * memo_ls[n - 1 - i][j];
      } else {
        res += pow(2, j) * (n - i - 1 - memo_ls[n - 1 - i][j]);
      }
    }
  }
  cout << res << endl;
}
