import bisect

N=int(input())
L=list(map(int,input().split()))

L=sorted(L)

ans=0
for i in range(N-1):
    for k in range(i+1,N-1):
        a=L[i]+L[k]
        b=bisect.bisect_left(L,a)
        ans=ans+(b-k-1)

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=sorted(L) L sorted(L) sorted L ans=0 ans 0 for i in range(N-1):
    for k in range(i+1,N-1):
        a=L[i]+L[k]
        b=bisect.bisect_left(L,a)
        ans=ans+(b-k-1) i range(N-1) range N-1 N 1 for k in range(i+1,N-1):
        a=L[i]+L[k]
        b=bisect.bisect_left(L,a)
        ans=ans+(b-k-1) k range(i+1,N-1) range i+1 i 1 N-1 N 1 a=L[i]+L[k] a L[i]+L[k] L[i] L i L[k] L k b=bisect.bisect_left(L,a) b bisect.bisect_left(L,a) bisect.bisect_left bisect bisect_left L a ans=ans+(b-k-1) ans ans+(b-k-1) ans b-k-1 b-k b k 1 print(ans) print ans ans=0 0 ans b=bisect.bisect_left(L,a) bisect.bisect_left(L,a) b L=list(map(int,input().split())) list(map(int,input().split())) L N=int(input()) int(input()) N ans=ans+(b-k-1) ans+(b-k-1) ans L=sorted(L) sorted(L) L a=L[i]+L[k] L[i]+L[k] a
import bisect

N=int(input())
L=list(map(int,input().split()))

L=sorted(L)

ans=0
for i in range(N-1):
    for k in range(i+1,N-1):
        a=L[i]+L[k]
        b=bisect.bisect_left(L,a)
        ans=ans+(b-k-1)

print(ans)