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