import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-1, 1, -1):
    for j in range(i-1, 0, -1):
        a, b = L[i], L[j]
        c = a - b + 1
        if c > b: continue
        ans += (j - bisect.bisect_left(L, c))
print(ans) import bisect bisect N = int(input()) N int(input()) int input() input L = list(map(int, input().split())) L list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split L.sort() L.sort L sort ans = 0 ans 0 for i in range(N-1, 1, -1):
    for j in range(i-1, 0, -1):
        a, b = L[i], L[j]
        c = a - b + 1
        if c > b: continue
        ans += (j - bisect.bisect_left(L, c)) i range(N-1, 1, -1) range N-1 N 1 1 -1 for j in range(i-1, 0, -1):
        a, b = L[i], L[j]
        c = a - b + 1
        if c > b: continue
        ans += (j - bisect.bisect_left(L, c)) j range(i-1, 0, -1) range i-1 i 1 0 -1 a, b = L[i], L[j] a L[i] L i b L[j] L j c = a - b + 1 c a - b + 1 a - b a b 1 if c > b: continue
         c > b c b ans += (j - bisect.bisect_left(L, c)) ans j - bisect.bisect_left(L, c) j bisect.bisect_left(L, c) bisect.bisect_left bisect bisect_left L c print(ans) print ans c = a - b + 1 a - b + 1 c a, b = L[i], L[j] L[i] a ans = 0 0 ans L = list(map(int, input().split())) list(map(int, input().split())) L ans += (j - bisect.bisect_left(L, c)) j - bisect.bisect_left(L, c) ans N = int(input()) int(input()) N b = L[i], L[j] L[j] b
import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-1, 1, -1):
    for j in range(i-1, 0, -1):
        a, b = L[i], L[j]
        c = a - b + 1
        if c > b: continue
        ans += (j - bisect.bisect_left(L, c))
print(ans)