from bisect import bisect_left

N = int(input())

L = list(map(int, input().split()))
L.sort()

ans = 0


for i in range(N):
    for j in range(i + 1, N):
        c = L[i] + L[j]
        # a+bが入る場所を返す
        idx = bisect_left(L, c)
        ans += max(0, idx - (j + 1))

print(ans) from bisect import bisect_left 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.sort() L.sort L sort ans = 0 ans 0 for i in range(N):
    for j in range(i + 1, N):
        c = L[i] + L[j]
        # a+bが入る場所を返す
        idx = bisect_left(L, c)
        ans += max(0, idx - (j + 1)) i range(N) range N for j in range(i + 1, N):
        c = L[i] + L[j]
        # a+bが入る場所を返す
        idx = bisect_left(L, c)
        ans += max(0, idx - (j + 1)) j range(i + 1, N) range i + 1 i 1 N c = L[i] + L[j] c L[i] + L[j] L[i] L i L[j] L j idx = bisect_left(L, c) idx bisect_left(L, c) bisect_left L c ans += max(0, idx - (j + 1)) ans max(0, idx - (j + 1)) max 0 idx - (j + 1) idx j + 1 j 1 print(ans) print ans c = L[i] + L[j] L[i] + L[j] c idx = bisect_left(L, c) bisect_left(L, c) idx N = int(input()) int(input()) N L = list(map(int, input().split())) list(map(int, input().split())) L ans = 0 0 ans ans += max(0, idx - (j + 1)) max(0, idx - (j + 1)) ans
from bisect import bisect_left

N = int(input())

L = list(map(int, input().split()))
L.sort()

ans = 0


for i in range(N):
    for j in range(i + 1, N):
        c = L[i] + L[j]
        # a+bが入る場所を返す
        idx = bisect_left(L, c)
        ans += max(0, idx - (j + 1))

print(ans)
