import bisect
N = int(input())
L = list(map(int,input().split()))
L = sorted(L,reverse = False)

cnt = 0
# a の index
for a in range(len(L)):
    # b の index
    for b in range(a+1,len(L)):
        # c が取りうる最大の index
        c_idx = bisect.bisect_left(L,L[a]+L[b]) - 1
        cnt += c_idx - b
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 = sorted(L,reverse = False) L sorted(L,reverse = False) sorted L reverse = False reverse False cnt = 0 cnt 0 for a in range(len(L)):
    # b の index
    for b in range(a+1,len(L)):
        # c が取りうる最大の index
        c_idx = bisect.bisect_left(L,L[a]+L[b]) - 1
        cnt += c_idx - b a range(len(L)) range len(L) len L for b in range(a+1,len(L)):
        # c が取りうる最大の index
        c_idx = bisect.bisect_left(L,L[a]+L[b]) - 1
        cnt += c_idx - b b range(a+1,len(L)) range a+1 a 1 len(L) len L c_idx = bisect.bisect_left(L,L[a]+L[b]) - 1 c_idx bisect.bisect_left(L,L[a]+L[b]) - 1 bisect.bisect_left(L,L[a]+L[b]) bisect.bisect_left bisect bisect_left L L[a]+L[b] L[a] L a L[b] L b 1 cnt += c_idx - b cnt c_idx - b c_idx b print(cnt) print cnt L = list(map(int,input().split())) list(map(int,input().split())) L cnt += c_idx - b c_idx - b cnt L = sorted(L,reverse = False) sorted(L,reverse = False) L N = int(input()) int(input()) N cnt = 0 0 cnt c_idx = bisect.bisect_left(L,L[a]+L[b]) - 1 bisect.bisect_left(L,L[a]+L[b]) - 1 c_idx
import bisect
N = int(input())
L = list(map(int,input().split()))
L = sorted(L,reverse = False)

cnt = 0
# a の index
for a in range(len(L)):
    # b の index
    for b in range(a+1,len(L)):
        # c が取りうる最大の index
        c_idx = bisect.bisect_left(L,L[a]+L[b]) - 1
        cnt += c_idx - b
print(cnt)