from bisect import bisect_left
n=int(input())
lst=sorted(map(int,input().split()))
ans=0
for i in range(n):
    for j in range(i+1,n):
        p=lst[i]+lst[j]
        out=bisect_left(lst,p)
        ans+=(out-j-1)
print(ans) from bisect import bisect_left n=int(input()) n int(input()) int input() input lst=sorted(map(int,input().split())) lst sorted(map(int,input().split())) sorted map(int,input().split()) map int input().split() ().split () input split ans=0 ans 0 for i in range(n):
    for j in range(i+1,n):
        p=lst[i]+lst[j]
        out=bisect_left(lst,p)
        ans+=(out-j-1) i range(n) range n for j in range(i+1,n):
        p=lst[i]+lst[j]
        out=bisect_left(lst,p)
        ans+=(out-j-1) j range(i+1,n) range i+1 i 1 n p=lst[i]+lst[j] p lst[i]+lst[j] lst[i] lst i lst[j] lst j out=bisect_left(lst,p) out bisect_left(lst,p) bisect_left lst p ans+=(out-j-1) ans out-j-1 out-j out j 1 print(ans) print ans ans=0 0 ans out=bisect_left(lst,p) bisect_left(lst,p) out n=int(input()) int(input()) n ans+=(out-j-1) out-j-1 ans p=lst[i]+lst[j] lst[i]+lst[j] p lst=sorted(map(int,input().split())) sorted(map(int,input().split())) lst
from bisect import bisect_left
n=int(input())
lst=sorted(map(int,input().split()))
ans=0
for i in range(n):
    for j in range(i+1,n):
        p=lst[i]+lst[j]
        out=bisect_left(lst,p)
        ans+=(out-j-1)
print(ans)