#include using namespace std; using namespace chrono; #if __has_include() #include using namespace atcoder; #endif int main() { int64_t n; cin >> n; vector as(n); for (auto &&a : as) { cin >> a; } ranges::sort(as); map mp; for (auto &&a : as) { mp[a]++; } int64_t ans = 0; for (auto [k, v] : mp) { if (2 <= v) { auto itr = ranges::lower_bound(as, 2 * k); int64_t t = distance(as.begin(), itr); t -= v; ans += v * (v - 1) / 2 * t; } } cout << ans << endl; return 0; }