import bisect

N=int(eval(input()))

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

L.sort()

ans=0

for n in range(1,N):

  b=L[n]

  for k in range(n):

    a=L[k]

    index=bisect.bisect_left(L,a+b)

    ans+=max(0,index-n-1)

print(ans)
import bisect

N = int(eval(input()))

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

L.sort()

ans = 0



for i in range(N-2):

    a = L[i]

    for j in range(i+1,N-1):

        b = L[j]

        c = bisect.bisect_left(L,a+b)

        ans += c-j-1

print(ans)

import bisect

N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
for n in range(1, N):
    b = L[n]
    for k in range(n):
        a = L[k]
        index = bisect.bisect_left(L, a + b)
        ans += max(0, index - n - 1)
print(ans)

import bisect

N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N - 2):
    a = L[i]
    for j in range(i + 1, N - 1):
        b = L[j]
        c = bisect.bisect_left(L, a + b)
        ans += c - j - 1
print(ans)

-for n in range(1, N): -    b = L[n] -    for k in range(n): -        a = L[k] -        index = bisect.bisect_left(L, a + b) -        ans += max(0, index - n - 1) +for i in range(N - 2): +    a = L[i] +    for j in range(i + 1, N - 1): +        b = L[j] +        c = bisect.bisect_left(L, a + b) +        ans += c - j - 1