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