from bisect import bisect_left



N = int(eval(input()))

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

L.sort()

count = 0

for i in range(N):

    for j in range(i+1, N):

        max_len = L[i] + L[j]

        count += bisect_left(L, max_len) - j - 1

print(count)

from bisect import bisect_left

import sys

input = sys.stdin.readline



N = int(eval(input()))

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

L.sort()

ans = 0

for i in range(N-1):

    for j in range(i+1, N):

        l = L[i] + L[j]

        k = bisect_left(L, l)

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

print(ans)
from bisect import bisect_left

N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
count = 0
for i in range(N):
    for j in range(i + 1, N):
        max_len = L[i] + L[j]
        count += bisect_left(L, max_len) - j - 1
print(count)

from bisect import bisect_left
import sys

input = sys.stdin.readline
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        l = L[i] + L[j]
        k = bisect_left(L, l)
        ans += max(0, k - j - 1)
print(ans)

+import sys +input = sys.stdin.readline -count = 0 -for i in range(N): +ans = 0 +for i in range(N - 1): -        max_len = L[i] + L[j] -        count += bisect_left(L, max_len) - j - 1 -print(count) +        l = L[i] + L[j] +        k = bisect_left(L, l) +        ans += max(0, k - j - 1) +print(ans)