#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> bitCount(32, 0); // Count of '1's at each bit position
for (int i = 0; i < n; ++i) {
int x;
cin >> x;
for (int j = 0; j < 32; ++j) {
if (x & (1 << j)) {
bitCount[j]++;
}
}
}
long long result = 0;
bool valid = true;
for (int j = 31; j >= 0 && valid; --j) { // Start from the most significant bit
if (bitCount[j] > 1) { // If there is more than one '1' at this bit position
int ones = 0, zeros = 0;
for (int k = 0; k < j; ++k) {
if (bitCount[k] > n - bitCount[k]) { // Check if 1s are more than 0s in lower bits
ones++;
} else {
zeros++;
if (zeros > ones) { // If 0s become more than 1s, then this pair cannot satisfy the condition
valid = false;
break;
}
}
}
if (valid) {
result += bitCount[j] * (bitCount[j] - 1) / 2; // Combination C(bitCount[j], 2)
}
}
}
cout << result << endl;
return 0;
}