import bisect

n = int(input())

L = list(map(int,input().split()))

A = sorted(L)

ans = 0

for i in range(n):
    for j in range(i+1,n):
        total = L[i] + L[j]
        ans += bisect.bisect_left(A,total) - (j+1)

print(ans)   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 A = sorted(L) A sorted(L) sorted L ans = 0 ans 0 for i in range(n):
    for j in range(i+1,n):
        total = L[i] + L[j]
        ans += bisect.bisect_left(A,total) - (j+1) i range(n) range n for j in range(i+1,n):
        total = L[i] + L[j]
        ans += bisect.bisect_left(A,total) - (j+1) j range(i+1,n) range i+1 i 1 n total = L[i] + L[j] total L[i] + L[j] L[i] L i L[j] L j ans += bisect.bisect_left(A,total) - (j+1) ans bisect.bisect_left(A,total) - (j+1) bisect.bisect_left(A,total) bisect.bisect_left bisect bisect_left A total j+1 j 1 print(ans) print ans total = L[i] + L[j] L[i] + L[j] total ans += bisect.bisect_left(A,total) - (j+1) bisect.bisect_left(A,total) - (j+1) ans A = sorted(L) sorted(L) A L = list(map(int,input().split())) list(map(int,input().split())) L n = int(input()) int(input()) n ans = 0 0 ans
import bisect

n = int(input())

L = list(map(int,input().split()))

A = sorted(L)

ans = 0

for i in range(n):
    for j in range(i+1,n):
        total = L[i] + L[j]
        ans += bisect.bisect_left(A,total) - (j+1)

print(ans)  
