import bisect
n = int(input())
L = list(map(int,input().split()))

L.sort()
c=0
for i in range(n-2):
    ci=L[i]
    for j in range(i+1,n-1):
        cij = ci+L[j]
        c += bisect.bisect_left(L,cij,j+1,n)-j-1

print(c) 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.sort() L.sort L sort c=0 c 0 for i in range(n-2):
    ci=L[i]
    for j in range(i+1,n-1):
        cij = ci+L[j]
        c += bisect.bisect_left(L,cij,j+1,n)-j-1 i range(n-2) range n-2 n 2 ci=L[i] ci L[i] L i for j in range(i+1,n-1):
        cij = ci+L[j]
        c += bisect.bisect_left(L,cij,j+1,n)-j-1 j range(i+1,n-1) range i+1 i 1 n-1 n 1 cij = ci+L[j] cij ci+L[j] ci L[j] L j c += bisect.bisect_left(L,cij,j+1,n)-j-1 c bisect.bisect_left(L,cij,j+1,n)-j-1 bisect.bisect_left(L,cij,j+1,n)-j bisect.bisect_left(L,cij,j+1,n) bisect.bisect_left bisect bisect_left L cij j+1 j 1 n j 1 print(c) print c L = list(map(int,input().split())) list(map(int,input().split())) L c=0 0 c ci=L[i] L[i] ci n = int(input()) int(input()) n cij = ci+L[j] ci+L[j] cij c += bisect.bisect_left(L,cij,j+1,n)-j-1 bisect.bisect_left(L,cij,j+1,n)-j-1 c
import bisect
n = int(input())
L = list(map(int,input().split()))

L.sort()
c=0
for i in range(n-2):
    ci=L[i]
    for j in range(i+1,n-1):
        cij = ci+L[j]
        c += bisect.bisect_left(L,cij,j+1,n)-j-1

print(c)
