from bisect import bisect_right,bisect_left
N = int(input())
L = sorted(list(map(int,input().split())))
cnt = 0
for i in range(N-1):
    for j in range(i+1,N):
        a = L[i]
        b = L[j]
        indU = bisect_left(L,a+b)
        indL = bisect_right(L,b-a)
        if j<indU and i>= indL:
            cnt += indU-indL-2
        elif indL<=i<indU and j>=indU or i<indL and indL<=j<indU:
            cnt += indU-indL-1
        elif j<indL or i>=indU:
            cnt += indU-indL
print(cnt//3) from bisect import bisect_right,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-1):
    for j in range(i+1,N):
        a = L[i]
        b = L[j]
        indU = bisect_left(L,a+b)
        indL = bisect_right(L,b-a)
        if j<indU and i>= indL:
            cnt += indU-indL-2
        elif indL<=i<indU and j>=indU or i<indL and indL<=j<indU:
            cnt += indU-indL-1
        elif j<indL or i>=indU:
            cnt += indU-indL i range(N-1) range N-1 N 1 for j in range(i+1,N):
        a = L[i]
        b = L[j]
        indU = bisect_left(L,a+b)
        indL = bisect_right(L,b-a)
        if j<indU and i>= indL:
            cnt += indU-indL-2
        elif indL<=i<indU and j>=indU or i<indL and indL<=j<indU:
            cnt += indU-indL-1
        elif j<indL or i>=indU:
            cnt += indU-indL j range(i+1,N) range i+1 i 1 N a = L[i] a L[i] L i b = L[j] b L[j] L j indU = bisect_left(L,a+b) indU bisect_left(L,a+b) bisect_left L a+b a b indL = bisect_right(L,b-a) indL bisect_right(L,b-a) bisect_right L b-a b a if j<indU and i>= indL:
            cnt += indU-indL-2
        elif indL<=i<indU and j>=indU or i<indL and indL<=j<indU:
            cnt += indU-indL-1
        elif j<indL or i>=indU:
            cnt += indU-indL j<indU and i>= indL j<indU j indU i>= indL i indL cnt += indU-indL-2 cnt indU-indL-2 indU-indL indU indL 2 elif indL<=i<indU and j>=indU or i<indL and indL<=j<indU:
            cnt += indU-indL-1
         indL<=i<indU and j>=indU or i<indL and indL<=j<indU indL<=i<indU and j>=indU indL<=i<indU indL<=i indL i indU j>=indU j indU i<indL and indL<=j<indU i<indL i indL indL<=j<indU indL<=j indL j indU cnt += indU-indL-1 cnt indU-indL-1 indU-indL indU indL 1 elif j<indL or i>=indU:
            cnt += indU-indL j<indL or i>=indU j<indL j indL i>=indU i indU cnt += indU-indL cnt indU-indL indU indL print(cnt//3) print cnt//3 cnt 3 L = sorted(list(map(int,input().split()))) sorted(list(map(int,input().split()))) L N = int(input()) int(input()) N cnt = 0 0 cnt indL = bisect_right(L,b-a) bisect_right(L,b-a) indL cnt += indU-indL indU-indL cnt indU = bisect_left(L,a+b) bisect_left(L,a+b) indU cnt += indU-indL-1 indU-indL-1 cnt cnt += indU-indL-2 indU-indL-2 cnt a = L[i] L[i] a b = L[j] L[j] b
from bisect import bisect_right,bisect_left
N = int(input())
L = sorted(list(map(int,input().split())))
cnt = 0
for i in range(N-1):
    for j in range(i+1,N):
        a = L[i]
        b = L[j]
        indU = bisect_left(L,a+b)
        indL = bisect_right(L,b-a)
        if j<indU and i>= indL:
            cnt += indU-indL-2
        elif indL<=i<indU and j>=indU or i<indL and indL<=j<indU:
            cnt += indU-indL-1
        elif j<indL or i>=indU:
            cnt += indU-indL
print(cnt//3)