import sys

input=sys.stdin.readline

n=int(eval(input()))

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

l.sort()

import bisect

ans=0

for i in range(n):

    for j in range(i+1,n):

        x=bisect.bisect_left(l[j+1:n],l[i]+l[j])

        ans+=x

print(ans)

import sys

input=sys.stdin.readline

n=int(eval(input()))

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

l.sort()

import bisect

ans=0

for i in range(n):

    for j in range(i+1,n):

        x=bisect.bisect_left(l,l[i]+l[j],lo=j+1)

        ans+=x-j-1

print(ans)





    



import sys

input = sys.stdin.readline
n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
import bisect

ans = 0
for i in range(n):
    for j in range(i + 1, n):
        x = bisect.bisect_left(l[j + 1 : n], l[i] + l[j])
        ans += x
print(ans)

import sys

input = sys.stdin.readline
n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
import bisect

ans = 0
for i in range(n):
    for j in range(i + 1, n):
        x = bisect.bisect_left(l, l[i] + l[j], lo=j + 1)
        ans += x - j - 1
print(ans)

-        x = bisect.bisect_left(l[j + 1 : n], l[i] + l[j]) -        ans += x +        x = bisect.bisect_left(l, l[i] + l[j], lo=j + 1) +        ans += x - j - 1