# https://atcoder.jp/contests/abc143/tasks/abc143_d

from bisect import bisect_left, bisect_right

import sys

input = sys.stdin.readline

n = int(eval(input())) # 入力が1つ

# map(int, input().split()) # 入力が複数

L = [int(i) for i in input().split()]

L.sort()

pairs = []

for i in range(n):

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

        pairs.append((i, j))



ans = 0

for i, j in pairs:

    a, b = L[i], L[j]

    ans += bisect_left(L, a + b) - 1 - j

print(ans)
# https://atcoder.jp/contests/abc143/tasks/abc143_d

from bisect import bisect_left, bisect_right

import sys

input = sys.stdin.readline

n = int(eval(input())) # 入力が1つ

# map(int, input().split()) # 入力が複数

L = [int(i) for i in input().split()]

L.sort()

ans = 0

for i in range(n):

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

        a, b = L[i], L[j]

        ans += bisect_left(L, a + b) - 1 - j

print(ans)
# https://atcoder.jp/contests/abc143/tasks/abc143_d
from bisect import bisect_left, bisect_right
import sys

input = sys.stdin.readline
n = int(eval(input()))  # 入力が1つ
# map(int, input().split()) # 入力が複数
L = [int(i) for i in input().split()]
L.sort()
pairs = []
for i in range(n):
    for j in range(i + 1, n):
        pairs.append((i, j))
ans = 0
for i, j in pairs:
    a, b = L[i], L[j]
    ans += bisect_left(L, a + b) - 1 - j
print(ans)

# https://atcoder.jp/contests/abc143/tasks/abc143_d
from bisect import bisect_left, bisect_right
import sys

input = sys.stdin.readline
n = int(eval(input()))  # 入力が1つ
# map(int, input().split()) # 入力が複数
L = [int(i) for i in input().split()]
L.sort()
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        a, b = L[i], L[j]
        ans += bisect_left(L, a + b) - 1 - j
print(ans)

-pairs = [] +ans = 0 -        pairs.append((i, j)) -ans = 0 -for i, j in pairs: -    a, b = L[i], L[j] -    ans += bisect_left(L, a + b) - 1 - j +        a, b = L[i], L[j] +        ans += bisect_left(L, a + b) - 1 - j