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):
        x = L[i] + L[j]
        y = bisect_left(L, x)
        ans += y - 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):
        x = L[i] + L[j]
        y = bisect_left(L, x)
        ans += y - j - 1 i range(N) range N for j in range(i+1, N):
        x = L[i] + L[j]
        y = bisect_left(L, x)
        ans += y - j - 1 j range(i+1, N) range i+1 i 1 N x = L[i] + L[j] x L[i] + L[j] L[i] L i L[j] L j y = bisect_left(L, x) y bisect_left(L, x) bisect_left L x ans += y - j - 1 ans y - j - 1 y - j y j 1 print(ans) print ans ans += y - j - 1 y - j - 1 ans y = bisect_left(L, x) bisect_left(L, x) y L = list(map(int, input().split())) list(map(int, input().split())) L x = L[i] + L[j] L[i] + L[j] x ans = 0 0 ans N = int(input()) int(input()) N
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):
        x = L[i] + L[j]
        y = bisect_left(L, x)
        ans += y - j - 1
print(ans)