import bisect

N = int(input())
L = [int(n) for n in input().split()]
L = sorted(L)

total = 0

for i in range(N - 2):
    a = L[i]
    for j in range(i + 1, N - 1):
        b = L[j]
        right_endpoint = bisect.bisect_left(L, a+b, j)
        total += right_endpoint - j - 1

print(total) import bisect bisect N = int(input()) N int(input()) int input() input int(n) for n in input().split() for n in input().split() n input().split() ().split () input split for n in input().split() int(n) int n L = [int(n) for n in input().split()] L [int(n) for n in input().split()] L = sorted(L) L sorted(L) sorted L total = 0 total 0 for i in range(N - 2):
    a = L[i]
    for j in range(i + 1, N - 1):
        b = L[j]
        right_endpoint = bisect.bisect_left(L, a+b, j)
        total += right_endpoint - j - 1 i range(N - 2) range N - 2 N 2 a = L[i] a L[i] L i for j in range(i + 1, N - 1):
        b = L[j]
        right_endpoint = bisect.bisect_left(L, a+b, j)
        total += right_endpoint - j - 1 j range(i + 1, N - 1) range i + 1 i 1 N - 1 N 1 b = L[j] b L[j] L j right_endpoint = bisect.bisect_left(L, a+b, j) right_endpoint bisect.bisect_left(L, a+b, j) bisect.bisect_left bisect bisect_left L a+b a b j total += right_endpoint - j - 1 total right_endpoint - j - 1 right_endpoint - j right_endpoint j 1 print(total) print total b = L[j] L[j] b L = [int(n) for n in input().split()] [int(n) for n in input().split()] L right_endpoint = bisect.bisect_left(L, a+b, j) bisect.bisect_left(L, a+b, j) right_endpoint L = sorted(L) sorted(L) L N = int(input()) int(input()) N a = L[i] L[i] a total = 0 0 total total += right_endpoint - j - 1 right_endpoint - j - 1 total
import bisect

N = int(input())
L = [int(n) for n in input().split()]
L = sorted(L)

total = 0

for i in range(N - 2):
    a = L[i]
    for j in range(i + 1, N - 1):
        b = L[j]
        right_endpoint = bisect.bisect_left(L, a+b, j)
        total += right_endpoint - j - 1

print(total)