import bisect

import sys



input = sys.stdin.readline





def read_i():

    return list(map(int, input().split()))





n = int(eval(input()))

ls = sorted(read_i())

ls2 = ls[::-1]

res = 0

for i, x in enumerate(ls2):

    for j, y in enumerate(ls2[i + 1:], i + 1):

        res += n - j - 1 - bisect.bisect(ls[:-(j + 1)], x - y)

print(res)
import bisect

import sys



input = sys.stdin.readline





def read_i():

    return list(map(int, input().split()))





n = int(eval(input()))

ls = sorted(read_i())

res = 0

for i in range(n - 2):

    x = ls[i]

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

        y = ls[j]

        res += bisect.bisect_left(ls, x + y) - j - 1

print(res)
import bisect
import sys

input = sys.stdin.readline


def read_i():
    return list(map(int, input().split()))


n = int(eval(input()))
ls = sorted(read_i())
ls2 = ls[::-1]
res = 0
for i, x in enumerate(ls2):
    for j, y in enumerate(ls2[i + 1 :], i + 1):
        res += n - j - 1 - bisect.bisect(ls[: -(j + 1)], x - y)
print(res)

import bisect
import sys

input = sys.stdin.readline


def read_i():
    return list(map(int, input().split()))


n = int(eval(input()))
ls = sorted(read_i())
res = 0
for i in range(n - 2):
    x = ls[i]
    for j in range(i + 1, n - 1):
        y = ls[j]
        res += bisect.bisect_left(ls, x + y) - j - 1
print(res)

-ls2 = ls[::-1] -for i, x in enumerate(ls2): -    for j, y in enumerate(ls2[i + 1 :], i + 1): -        res += n - j - 1 - bisect.bisect(ls[: -(j + 1)], x - y) +for i in range(n - 2): +    x = ls[i] +    for j in range(i + 1, n - 1): +        y = ls[j] +        res += bisect.bisect_left(ls, x + y) - j - 1