from bisect import bisect_left

N = int(input())
L = sorted(list(map(int,input().split())))
cnt = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        tmp = bisect_left(L,L[i]+L[j])
        cnt += tmp - j - 1

print(cnt) from bisect import bisect_left N = int(input()) N int(input()) int input() input L = sorted(list(map(int,input().split()))) L sorted(list(map(int,input().split()))) sorted list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split cnt = 0 cnt 0 for i in range(N-2):
    for j in range(i+1,N-1):
        tmp = bisect_left(L,L[i]+L[j])
        cnt += tmp - j - 1 i range(N-2) range N-2 N 2 for j in range(i+1,N-1):
        tmp = bisect_left(L,L[i]+L[j])
        cnt += tmp - j - 1 j range(i+1,N-1) range i+1 i 1 N-1 N 1 tmp = bisect_left(L,L[i]+L[j]) tmp bisect_left(L,L[i]+L[j]) bisect_left L L[i]+L[j] L[i] L i L[j] L j cnt += tmp - j - 1 cnt tmp - j - 1 tmp - j tmp j 1 print(cnt) print cnt L = sorted(list(map(int,input().split()))) sorted(list(map(int,input().split()))) L tmp = bisect_left(L,L[i]+L[j]) bisect_left(L,L[i]+L[j]) tmp cnt += tmp - j - 1 tmp - j - 1 cnt cnt = 0 0 cnt N = int(input()) int(input()) N
from bisect import bisect_left

N = int(input())
L = sorted(list(map(int,input().split())))
cnt = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        tmp = bisect_left(L,L[i]+L[j])
        cnt += tmp - j - 1

print(cnt)
