#include #include #include using namespace std; using ll = long long; #define rep(i, s, t) for (ll i = s; i < (ll)(t); i++) #define all(x) begin(x), end(x) template bool chmin(T& x, T y) { return x > y ? (x = y, true) : false; } template bool chmax(T& x, T y) { return x < y ? (x = y, true) : false; } struct IOST { IOST() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20); } } IOST; void solve() { int n; cin >> n; vector a(n); rep(i, 0, n) cin >> a[i]; map mp, smp; rep(i, 0, n) mp[a[i]]++; { ll tmp = 0; for (auto [x, y] : mp) { tmp += y; smp[x] = tmp; } } ll ans = 0; for (auto [x, y] : mp) { ll tmp = y * (y - 1) / 2; auto itr = smp.lower_bound(x * 2); itr--; tmp *= itr->second - y; ans += tmp; } cout << ans << "\n"; } int main() { int t = 1; // cin >> t; rep(i, 0, t) solve(); }