N = int(input()) A = list(map(int, input().split())) from collections import defaultdict from bisect import bisect_left d = defaultdict(int) for i in range(N): d[A[i]] += 1 cnt = sorted(list(d.items())) S = [0] * (len(cnt) + 1) for i in range(len(cnt)): S[i+1] = S[i] + cnt[i][1] * (cnt[i][1] - 1) // 2 ans = 0 for i in range(len(cnt)): ans += cnt[i][1] * (S[-1] - S[bisect_left(cnt, (cnt[i][0]//2+1,))] - cnt[i][1] * (cnt[i][1] - 1) // 2) print(ans)