import bisect
n=int(input())
l=sorted(list(map(int,input().split())))
g=0
for ai in range(n-2):
    for bi in range(ai+1,n-1):
        g+=max(0,bisect.bisect_left(l,l[bi]+l[ai])-1-bi)
print(g) import bisect bisect n=int(input()) n int(input()) int input() input l=sorted(list(map(int,input().split()))) l sorted(list(map(int,input().split()))) sorted list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split g=0 g 0 for ai in range(n-2):
    for bi in range(ai+1,n-1):
        g+=max(0,bisect.bisect_left(l,l[bi]+l[ai])-1-bi) ai range(n-2) range n-2 n 2 for bi in range(ai+1,n-1):
        g+=max(0,bisect.bisect_left(l,l[bi]+l[ai])-1-bi) bi range(ai+1,n-1) range ai+1 ai 1 n-1 n 1 g+=max(0,bisect.bisect_left(l,l[bi]+l[ai])-1-bi) g max(0,bisect.bisect_left(l,l[bi]+l[ai])-1-bi) max 0 bisect.bisect_left(l,l[bi]+l[ai])-1-bi bisect.bisect_left(l,l[bi]+l[ai])-1 bisect.bisect_left(l,l[bi]+l[ai]) bisect.bisect_left bisect bisect_left l l[bi]+l[ai] l[bi] l bi l[ai] l ai 1 bi print(g) print g g=0 0 g l=sorted(list(map(int,input().split()))) sorted(list(map(int,input().split()))) l g+=max(0,bisect.bisect_left(l,l[bi]+l[ai])-1-bi) max(0,bisect.bisect_left(l,l[bi]+l[ai])-1-bi) g n=int(input()) int(input()) n
import bisect
n=int(input())
l=sorted(list(map(int,input().split())))
g=0
for ai in range(n-2):
    for bi in range(ai+1,n-1):
        g+=max(0,bisect.bisect_left(l,l[bi]+l[ai])-1-bi)
print(g)
