import bisect

n = int(eval(input()))

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

count = 0

l.sort(reverse = False)

for i in range(len(l)-1, 1, -1):

  for j in range(i-1, 0, -1):

    pt = bisect.bisect_right(l, l[i] - l[j])

    count += max(j - pt, 0)

print(count)



import bisect

n = int(eval(input()))

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

count = 0

l.sort()

for i in range(len(l)-1, 1, -1):

  for j in range(i-1, 0, -1):

    count += max(j - (bisect.bisect_right(l, l[i] - l[j])), 0)

print(count)



import bisect

n = int(eval(input()))
l = list(map(int, input().split()))
count = 0
l.sort(reverse=False)
for i in range(len(l) - 1, 1, -1):
    for j in range(i - 1, 0, -1):
        pt = bisect.bisect_right(l, l[i] - l[j])
        count += max(j - pt, 0)
print(count)

import bisect

n = int(eval(input()))
l = list(map(int, input().split()))
count = 0
l.sort()
for i in range(len(l) - 1, 1, -1):
    for j in range(i - 1, 0, -1):
        count += max(j - (bisect.bisect_right(l, l[i] - l[j])), 0)
print(count)

-l.sort(reverse=False) +l.sort() -        pt = bisect.bisect_right(l, l[i] - l[j]) -        count += max(j - pt, 0) +        count += max(j - (bisect.bisect_right(l, l[i] - l[j])), 0)