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

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

cnt = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        num = L[i] + L[j]
        third = bisect.bisect_left(L,num)
        if third > j:
            cnt += third - j - 1
print(cnt)