import bisect
n = int(input())
L = list(map(int, input().split()))
#%%
L.sort()

ans = 0
for i in range(n-2): # aを固定
    for j in range(i+1, n-1): # bを固定
        ab = L[i] + L[j]
        idx = bisect.bisect_left(L, ab, lo=j)
        ans += max(idx - (j+1), 0)

print(ans) 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.sort() L.sort L sort ans = 0 ans 0 for i in range(n-2): # aを固定
    for j in range(i+1, n-1): # bを固定
        ab = L[i] + L[j]
        idx = bisect.bisect_left(L, ab, lo=j)
        ans += max(idx - (j+1), 0) i range(n-2) range n-2 n 2 for j in range(i+1, n-1): # bを固定
        ab = L[i] + L[j]
        idx = bisect.bisect_left(L, ab, lo=j)
        ans += max(idx - (j+1), 0) j range(i+1, n-1) range i+1 i 1 n-1 n 1 ab = L[i] + L[j] ab L[i] + L[j] L[i] L i L[j] L j idx = bisect.bisect_left(L, ab, lo=j) idx bisect.bisect_left(L, ab, lo=j) bisect.bisect_left bisect bisect_left L ab lo=j lo j ans += max(idx - (j+1), 0) ans max(idx - (j+1), 0) max idx - (j+1) idx j+1 j 1 0 print(ans) print ans ans = 0 0 ans n = int(input()) int(input()) n L = list(map(int, input().split())) list(map(int, input().split())) L idx = bisect.bisect_left(L, ab, lo=j) bisect.bisect_left(L, ab, lo=j) idx ab = L[i] + L[j] L[i] + L[j] ab ans += max(idx - (j+1), 0) max(idx - (j+1), 0) ans
import bisect
n = int(input())
L = list(map(int, input().split()))
#%%
L.sort()

ans = 0
for i in range(n-2): # aを固定
    for j in range(i+1, n-1): # bを固定
        ab = L[i] + L[j]
        idx = bisect.bisect_left(L, ab, lo=j)
        ans += max(idx - (j+1), 0)

print(ans)
