import itertools
import bisect

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

L = sorted(L)

count = 0

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        x, y = L[i], L[j]
        limit = x + y
        index = bisect.bisect_left(L, limit)
        count += max(0, index - j - 1)

print(count) import itertools itertools import bisect bisect N = int(input()) N int(input()) int input() input L = list(map(int, input().split(' '))) L list(map(int, input().split(' '))) list map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' L = sorted(L) L sorted(L) sorted L count = 0 count 0 for i in range(N - 2):
    for j in range(i + 1, N - 1):
        x, y = L[i], L[j]
        limit = x + y
        index = bisect.bisect_left(L, limit)
        count += max(0, index - j - 1) i range(N - 2) range N - 2 N 2 for j in range(i + 1, N - 1):
        x, y = L[i], L[j]
        limit = x + y
        index = bisect.bisect_left(L, limit)
        count += max(0, index - j - 1) j range(i + 1, N - 1) range i + 1 i 1 N - 1 N 1 x, y = L[i], L[j] x L[i] L i y L[j] L j limit = x + y limit x + y x y index = bisect.bisect_left(L, limit) index bisect.bisect_left(L, limit) bisect.bisect_left bisect bisect_left L limit count += max(0, index - j - 1) count max(0, index - j - 1) max 0 index - j - 1 index - j index j 1 print(count) print count y = L[i], L[j] L[j] y x, y = L[i], L[j] L[i] x L = sorted(L) sorted(L) L index = bisect.bisect_left(L, limit) bisect.bisect_left(L, limit) index L = list(map(int, input().split(' '))) list(map(int, input().split(' '))) L limit = x + y x + y limit N = int(input()) int(input()) N count = 0 0 count count += max(0, index - j - 1) max(0, index - j - 1) count
import itertools
import bisect

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

L = sorted(L)

count = 0

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        x, y = L[i], L[j]
        limit = x + y
        index = bisect.bisect_left(L, limit)
        count += max(0, index - j - 1)

print(count)