from bisect import bisect_left

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):

    ans += bisect_left(l, l[i]+l[j], j+1, n) - j - 1

print(ans)

from bisect import bisect_left

n = int(eval(input()))

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

l.sort()

ans = 0

for a in range(n-2):

    for b in range(a+1, n-1):

        ans += bisect_left(l, l[a]+l[b]) - b - 1

print(ans)
from bisect import bisect_left

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):
        ans += bisect_left(l, l[i] + l[j], j + 1, n) - j - 1
print(ans)

from bisect import bisect_left

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

-for i in range(n - 2): -    for j in range(i + 1, n - 1): -        ans += bisect_left(l, l[i] + l[j], j + 1, n) - j - 1 +for a in range(n - 2): +    for b in range(a + 1, n - 1): +        ans += bisect_left(l, l[a] + l[b]) - b - 1