import bisect

N = int(eval(input()))

L = sorted([int(x) for x in input().split()])

cnt = 0

#print(L)

for i in range(N-2):

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

        #print(i, j)

        #print(bisect.bisect_left(L, L[i]+L[j]))

        cnt +=  bisect.bisect_left(L, L[i]+L[j]) - (j+1)

print(cnt)
import bisect

N = int(eval(input()))

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

L.sort()



ans = 0

for i in range(N-2):

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

        tmp = L[i]+L[j]

        point = bisect.bisect_left(L,tmp)

        ans += point - j - 1

print(ans)

        
import bisect

N = int(eval(input()))
L = sorted([int(x) for x in input().split()])
cnt = 0
# print(L)
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        # print(i, j)
        # print(bisect.bisect_left(L, L[i]+L[j]))
        cnt += bisect.bisect_left(L, L[i] + L[j]) - (j + 1)
print(cnt)

import bisect

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

-L = sorted([int(x) for x in input().split()]) -cnt = 0 -# print(L) +L = list(map(int, input().split())) +L.sort() +ans = 0 -        # print(i, j) -        # print(bisect.bisect_left(L, L[i]+L[j])) -        cnt += bisect.bisect_left(L, L[i] + L[j]) - (j + 1) -print(cnt) +        tmp = L[i] + L[j] +        point = bisect.bisect_left(L, tmp) +        ans += point - j - 1 +print(ans)