import bisect

N=int(input())
L=[int(i) for i in input().split()]

L.sort()
ans=0
for i in range(N-2):
    for j in range(i+1,N-1):
        x=L[i]+L[j]
        ans+=(bisect.bisect_left(L,x)-j-1)

print(ans) import bisect bisect N=int(input()) N int(input()) int input() input int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i L=[int(i) for i in input().split()] L [int(i) for i in input().split()] L.sort() L.sort L sort ans=0 ans 0 for i in range(N-2):
    for j in range(i+1,N-1):
        x=L[i]+L[j]
        ans+=(bisect.bisect_left(L,x)-j-1) i range(N-2) range N-2 N 2 for j in range(i+1,N-1):
        x=L[i]+L[j]
        ans+=(bisect.bisect_left(L,x)-j-1) j range(i+1,N-1) range i+1 i 1 N-1 N 1 x=L[i]+L[j] x L[i]+L[j] L[i] L i L[j] L j ans+=(bisect.bisect_left(L,x)-j-1) ans bisect.bisect_left(L,x)-j-1 bisect.bisect_left(L,x)-j bisect.bisect_left(L,x) bisect.bisect_left bisect bisect_left L x j 1 print(ans) print ans N=int(input()) int(input()) N ans=0 0 ans x=L[i]+L[j] L[i]+L[j] x ans+=(bisect.bisect_left(L,x)-j-1) bisect.bisect_left(L,x)-j-1 ans L=[int(i) for i in input().split()] [int(i) for i in input().split()] L
import bisect

N=int(input())
L=[int(i) for i in input().split()]

L.sort()
ans=0
for i in range(N-2):
    for j in range(i+1,N-1):
        x=L[i]+L[j]
        ans+=(bisect.bisect_left(L,x)-j-1)

print(ans)
