import bisect



n = int(eval(input()))

ListL = [int(i) for i in input().split()]



ListL.sort()

ans = 0



for i in reversed(list(range(2, n))):

	a = ListL[i]

	for j in reversed(list(range(1, i))):

		b = ListL[j]

		index = bisect.bisect_right(ListL, a-b)

		#print(a, b)

		if (index >= j):

			break

		else:

			ans += j - index



print(ans)
import bisect



n = int(eval(input()))

ListL = [int(i) for i in input().split()]



ListL.sort()

ans = 0



for i in reversed(list(range(2, n))):

	a = ListL[i]

	b = ListL[i-1]

	c = a - b + 1

	indexb = i - 1

	indexc = bisect.bisect_left(ListL, c)

	while(indexb > indexc):

		if (ListL[indexb] + ListL[indexc] > a):

			ans += indexb - indexc

			indexb -= 1

		else:

			indexc += 1



print(ans)
import bisect

n = int(eval(input()))
ListL = [int(i) for i in input().split()]
ListL.sort()
ans = 0
for i in reversed(list(range(2, n))):
    a = ListL[i]
    for j in reversed(list(range(1, i))):
        b = ListL[j]
        index = bisect.bisect_right(ListL, a - b)
        # print(a, b)
        if index >= j:
            break
        else:
            ans += j - index
print(ans)

import bisect

n = int(eval(input()))
ListL = [int(i) for i in input().split()]
ListL.sort()
ans = 0
for i in reversed(list(range(2, n))):
    a = ListL[i]
    b = ListL[i - 1]
    c = a - b + 1
    indexb = i - 1
    indexc = bisect.bisect_left(ListL, c)
    while indexb > indexc:
        if ListL[indexb] + ListL[indexc] > a:
            ans += indexb - indexc
            indexb -= 1
        else:
            indexc += 1
print(ans)

-    for j in reversed(list(range(1, i))): -        b = ListL[j] -        index = bisect.bisect_right(ListL, a - b) -        # print(a, b) -        if index >= j: -            break +    b = ListL[i - 1] +    c = a - b + 1 +    indexb = i - 1 +    indexc = bisect.bisect_left(ListL, c) +    while indexb > indexc: +        if ListL[indexb] + ListL[indexc] > a: +            ans += indexb - indexc +            indexb -= 1 -            ans += j - index +            indexc += 1