n = int(input()) a = [int(x) for x in input().split()] assert 3 <= n <= 3 * 10 ** 5 for x in a: assert 1 <= x <= 10 ** 9 from collections import defaultdict cnt = defaultdict(int) for x in a: cnt[x] += 1 a = list(sorted(set(a))) ans = 0 s = 0 for c in cnt.values(): s += c * (c - 1) // 2 ans -= c * c * (c - 1) // 2 idx = 0 for x in a: while a[idx] * 2 <= x: c = cnt[a[idx]] s -= c * (c - 1) // 2 idx += 1 ans += s * cnt[x] print(ans)