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):
        x = arr[i]+arr[j]
        ind = bisect.bisect_left(arr,x)
        ans+=(ind-j-1)
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):
        x = arr[i]+arr[j]
        ind = bisect.bisect_left(arr,x)
        ans+=(ind-j-1) i range(n-2) range n-2 n 2 for j in range(i+1,n-1):
        x = arr[i]+arr[j]
        ind = bisect.bisect_left(arr,x)
        ans+=(ind-j-1) j range(i+1,n-1) range i+1 i 1 n-1 n 1 x = arr[i]+arr[j] x arr[i]+arr[j] arr[i] arr i arr[j] arr j ind = bisect.bisect_left(arr,x) ind bisect.bisect_left(arr,x) bisect.bisect_left bisect bisect_left arr x ans+=(ind-j-1) ans ind-j-1 ind-j ind j 1 print(ans) print ans ans+=(ind-j-1) ind-j-1 ans n = int(input()) int(input()) n ans = 0 0 ans x = arr[i]+arr[j] arr[i]+arr[j] x ind = bisect.bisect_left(arr,x) bisect.bisect_left(arr,x) ind arr = list(map(int,input().split())) list(map(int,input().split())) arr
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):
        x = arr[i]+arr[j]
        ind = bisect.bisect_left(arr,x)
        ans+=(ind-j-1)
print(ans)