import bisect
N=int(input())
arr=list(map(int,input().split()))

arr.sort()

ans=0

for i in range(N-2):
    for j in range(i+1,N-1):
        k=bisect.bisect_left(arr,arr[i]+arr[j])
        if k>j:
            ans+=k-j-1
        else:
            pass
print(ans) import bisect bisect N=int(input()) N int(input()) int input() input arr=list(map(int,input().split())) arr list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split arr.sort() arr.sort arr sort ans=0 ans 0 for i in range(N-2):
    for j in range(i+1,N-1):
        k=bisect.bisect_left(arr,arr[i]+arr[j])
        if k>j:
            ans+=k-j-1
        else:
            pass i range(N-2) range N-2 N 2 for j in range(i+1,N-1):
        k=bisect.bisect_left(arr,arr[i]+arr[j])
        if k>j:
            ans+=k-j-1
        else:
            pass j range(i+1,N-1) range i+1 i 1 N-1 N 1 k=bisect.bisect_left(arr,arr[i]+arr[j]) k bisect.bisect_left(arr,arr[i]+arr[j]) bisect.bisect_left bisect bisect_left arr arr[i]+arr[j] arr[i] arr i arr[j] arr j if k>j:
            ans+=k-j-1
        else:
            pass k>j k j ans+=k-j-1 ans k-j-1 k-j k j 1 print(ans) print ans ans+=k-j-1 k-j-1 ans ans=0 0 ans arr=list(map(int,input().split())) list(map(int,input().split())) arr N=int(input()) int(input()) N k=bisect.bisect_left(arr,arr[i]+arr[j]) bisect.bisect_left(arr,arr[i]+arr[j]) k
import bisect
N=int(input())
arr=list(map(int,input().split()))

arr.sort()

ans=0

for i in range(N-2):
    for j in range(i+1,N-1):
        k=bisect.bisect_left(arr,arr[i]+arr[j])
        if k>j:
            ans+=k-j-1
        else:
            pass
print(ans)