#include <iostream>
#include <vector>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<int> nums(n);
for (int i = 0; i < n; ++i) {
cin >> nums[i];
}
long long result = 0;
for (int i = 0; i < n; ++i) {
int highestBit = 0;
while ((nums[i] >> highestBit) & 1 == 0) {
++highestBit;
}
for (int j = i + 1; j < n; ++j) {
if (((nums[j] >> highestBit) & 1) && (nums[i] & nums[j]) > (nums[i] ^ nums[j])) {
++result;
}
}
}
cout << result << endl;
return 0;
}