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