from bisect import bisect_left
n=int(input())
a=list(map(int,input().split()))
a.sort()

ans=0
# print(a)
for i in range(1,n-1):
    for j in range(0,i):
        k=bisect_left(a,a[i]+a[j])-i-1
        # print(f"i{i} j{j} bisect{bisect_left(a,a[i]+a[j])}")
        ans=ans+k
print(ans) from bisect import bisect_left n=int(input()) n int(input()) int input() input a=list(map(int,input().split())) a list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split a.sort() a.sort a sort ans=0 ans 0 for i in range(1,n-1):
    for j in range(0,i):
        k=bisect_left(a,a[i]+a[j])-i-1
        # print(f"i{i} j{j} bisect{bisect_left(a,a[i]+a[j])}")
        ans=ans+k i range(1,n-1) range 1 n-1 n 1 for j in range(0,i):
        k=bisect_left(a,a[i]+a[j])-i-1
        # print(f"i{i} j{j} bisect{bisect_left(a,a[i]+a[j])}")
        ans=ans+k j range(0,i) range 0 i k=bisect_left(a,a[i]+a[j])-i-1 k bisect_left(a,a[i]+a[j])-i-1 bisect_left(a,a[i]+a[j])-i bisect_left(a,a[i]+a[j]) bisect_left a a[i]+a[j] a[i] a i a[j] a j i 1 ans=ans+k ans ans+k ans k print(ans) print ans ans=ans+k ans+k ans n=int(input()) int(input()) n a=list(map(int,input().split())) list(map(int,input().split())) a ans=0 0 ans k=bisect_left(a,a[i]+a[j])-i-1 bisect_left(a,a[i]+a[j])-i-1 k
from bisect import bisect_left
n=int(input())
a=list(map(int,input().split()))
a.sort()

ans=0
# print(a)
for i in range(1,n-1):
    for j in range(0,i):
        k=bisect_left(a,a[i]+a[j])-i-1
        # print(f"i{i} j{j} bisect{bisect_left(a,a[i]+a[j])}")
        ans=ans+k
print(ans)
