import bisect

n=int(input())
l=list(map(int,input().split()))

l.sort()

ans=0
for i in range(n):
  for j in range(i+1,n):
    a=l[i]
    b=l[j]
    le=bisect.bisect_left(l,max(a-b,b-a)+1)
    ri=bisect.bisect_right(l,a+b-1)
    #print(le,ri)
    f=0
    if le<=i<=ri:
      f-=1
    if le<=j<=ri:
      f-=1
    if ri-le+f>0:
      ans+=ri-le+f
    #print(a,b,ans)

print(ans//3) 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 ans=0 ans 0 for i in range(n):
  for j in range(i+1,n):
    a=l[i]
    b=l[j]
    le=bisect.bisect_left(l,max(a-b,b-a)+1)
    ri=bisect.bisect_right(l,a+b-1)
    #print(le,ri)
    f=0
    if le<=i<=ri:
      f-=1
    if le<=j<=ri:
      f-=1
    if ri-le+f>0:
      ans+=ri-le+f
    #print(a,b,ans) i range(n) range n for j in range(i+1,n):
    a=l[i]
    b=l[j]
    le=bisect.bisect_left(l,max(a-b,b-a)+1)
    ri=bisect.bisect_right(l,a+b-1)
    #print(le,ri)
    f=0
    if le<=i<=ri:
      f-=1
    if le<=j<=ri:
      f-=1
    if ri-le+f>0:
      ans+=ri-le+f
    #print(a,b,ans) j range(i+1,n) range i+1 i 1 n a=l[i] a l[i] l i b=l[j] b l[j] l j le=bisect.bisect_left(l,max(a-b,b-a)+1) le bisect.bisect_left(l,max(a-b,b-a)+1) bisect.bisect_left bisect bisect_left l max(a-b,b-a)+1 max(a-b,b-a) max a-b a b b-a b a 1 ri=bisect.bisect_right(l,a+b-1) ri bisect.bisect_right(l,a+b-1) bisect.bisect_right bisect bisect_right l a+b-1 a+b a b 1 f=0 f 0 if le<=i<=ri:
      f-=1
     le<=i<=ri le<=i le i ri f-=1 f 1 if le<=j<=ri:
      f-=1
     le<=j<=ri le<=j le j ri f-=1 f 1 if ri-le+f>0:
      ans+=ri-le+f
    #print(a,b,ans) ri-le+f>0 ri-le+f ri-le ri le f 0 ans+=ri-le+f ans ri-le+f ri-le ri le f print(ans//3) print ans//3 ans 3 l=list(map(int,input().split())) list(map(int,input().split())) l f-=1 1 f le=bisect.bisect_left(l,max(a-b,b-a)+1) bisect.bisect_left(l,max(a-b,b-a)+1) le n=int(input()) int(input()) n ans=0 0 ans a=l[i] l[i] a f=0 0 f b=l[j] l[j] b f-=1 1 f ans+=ri-le+f ri-le+f ans ri=bisect.bisect_right(l,a+b-1) bisect.bisect_right(l,a+b-1) ri
import bisect

n=int(input())
l=list(map(int,input().split()))

l.sort()

ans=0
for i in range(n):
  for j in range(i+1,n):
    a=l[i]
    b=l[j]
    le=bisect.bisect_left(l,max(a-b,b-a)+1)
    ri=bisect.bisect_right(l,a+b-1)
    #print(le,ri)
    f=0
    if le<=i<=ri:
      f-=1
    if le<=j<=ri:
      f-=1
    if ri-le+f>0:
      ans+=ri-le+f
    #print(a,b,ans)

print(ans//3)