import sys

from bisect import bisect_left



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



N = ir()

L = lr()

L.sort()

answer = 0

for i in range(N-2):

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

        index = bisect_left(L, (L[i]+L[j]))

        answer += index - j - 1



print(answer)

import sys



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



N = ir()

L = lr()

L.sort()

answer = 0

for i in range(N-1, -1, -1):

    # iが一番大きい辺

    x = L[i]

    left = 0

    right = i - 1

    while left < right:

        if L[left] + L[right] <= x:

            left += 1

            continue

        answer += (right - left)

        right -= 1



print(answer)

import sys
from bisect import bisect_left

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
L = lr()
L.sort()
answer = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        index = bisect_left(L, (L[i] + L[j]))
        answer += index - j - 1
print(answer)

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
L = lr()
L.sort()
answer = 0
for i in range(N - 1, -1, -1):
    # iが一番大きい辺
    x = L[i]
    left = 0
    right = i - 1
    while left < right:
        if L[left] + L[right] <= x:
            left += 1
            continue
        answer += right - left
        right -= 1
print(answer)

-from bisect import bisect_left -for i in range(N - 2): -    for j in range(i + 1, N - 1): -        index = bisect_left(L, (L[i] + L[j])) -        answer += index - j - 1 +for i in range(N - 1, -1, -1): +    # iが一番大きい辺 +    x = L[i] +    left = 0 +    right = i - 1 +    while left < right: +        if L[left] + L[right] <= x: +            left += 1 +            continue +        answer += right - left +        right -= 1