n = int(eval(input()))

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



L.sort()

import bisect

ans = 0

for i in range(n-2):

    b = L[i]

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

        c = L[j]

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

        #print(b, c, j, p, p-j-1)

        ans += max(p-j-1, 0)

print(ans)
n = int(eval(input()))

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

L.sort()

#print(L)

import bisect

ans = 0

for i in range(n-2):

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

        k = bisect.bisect_left(L, L[i]+L[j])

        #print(i, j, k)

        ans += max(0, k-j-1)

print(ans)

n = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
import bisect

ans = 0
for i in range(n - 2):
    b = L[i]
    for j in range(i + 1, n - 1):
        c = L[j]
        p = bisect.bisect_left(L, b + c)
        # print(b, c, j, p, p-j-1)
        ans += max(p - j - 1, 0)
print(ans)

n = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
# print(L)
import bisect

ans = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        k = bisect.bisect_left(L, L[i] + L[j])
        # print(i, j, k)
        ans += max(0, k - j - 1)
print(ans)

+# print(L) -    b = L[i] -        c = L[j] -        p = bisect.bisect_left(L, b + c) -        # print(b, c, j, p, p-j-1) -        ans += max(p - j - 1, 0) +        k = bisect.bisect_left(L, L[i] + L[j]) +        # print(i, j, k) +        ans += max(0, k - j - 1)