import bisect

n = int(eval(input()))

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

s = 0

for i in range(0,n-2):

  a = l[i]

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

    b = l[j]

    s += bisect.bisect_left(l,a+b,j+1)-j-1

print(s)
import bisect

n = int(eval(input()))

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

s = 0

for i in range(0,n-2):

  a = l[i]

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

    b = l[j]

    s += bisect.bisect_left(l,a+b)-j-1

print(s)
import bisect

n = int(eval(input()))
l = sorted(list(map(int, input().split())))
s = 0
for i in range(0, n - 2):
    a = l[i]
    for j in range(i + 1, n - 1):
        b = l[j]
        s += bisect.bisect_left(l, a + b, j + 1) - j - 1
print(s)

import bisect

n = int(eval(input()))
l = sorted(list(map(int, input().split())))
s = 0
for i in range(0, n - 2):
    a = l[i]
    for j in range(i + 1, n - 1):
        b = l[j]
        s += bisect.bisect_left(l, a + b) - j - 1
print(s)

-        s += bisect.bisect_left(l, a + b, j + 1) - j - 1 +        s += bisect.bisect_left(l, a + b) - j - 1