#include <bits/stdc++.h>
using namespace std;
long long h = 10e9 + 7;
int a[300001];
int main() {
  long long ans = 0;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      ans += a[i] & a[j] + 1;
    }
  cout << ans;
}
