from bisect import bisect


from bisect import bisect_left

n = int(input())
lis = list(map(int, input().split()))

lis.sort()

cnt = 0
for i in range(n-2):
    a = lis[i]
    for j in range(i+1, n-1):
        b = lis[j]
        tmp = bisect_left(lis, a+b)
        
        cnt += tmp - 1 -j
    

print(cnt) from bisect import bisect from bisect import bisect_left n = int(input()) n int(input()) int input() input lis = list(map(int, input().split())) lis list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split lis.sort() lis.sort lis sort cnt = 0 cnt 0 for i in range(n-2):
    a = lis[i]
    for j in range(i+1, n-1):
        b = lis[j]
        tmp = bisect_left(lis, a+b)
        
        cnt += tmp - 1 -j
     i range(n-2) range n-2 n 2 a = lis[i] a lis[i] lis i for j in range(i+1, n-1):
        b = lis[j]
        tmp = bisect_left(lis, a+b)
        
        cnt += tmp - 1 -j
     j range(i+1, n-1) range i+1 i 1 n-1 n 1 b = lis[j] b lis[j] lis j tmp = bisect_left(lis, a+b) tmp bisect_left(lis, a+b) bisect_left lis a+b a b cnt += tmp - 1 -j cnt tmp - 1 -j tmp - 1 tmp 1 j print(cnt) print cnt lis = list(map(int, input().split())) list(map(int, input().split())) lis b = lis[j] lis[j] b cnt = 0 0 cnt n = int(input()) int(input()) n cnt += tmp - 1 -j tmp - 1 -j cnt a = lis[i] lis[i] a tmp = bisect_left(lis, a+b) bisect_left(lis, a+b) tmp
from bisect import bisect


from bisect import bisect_left

n = int(input())
lis = list(map(int, input().split()))

lis.sort()

cnt = 0
for i in range(n-2):
    a = lis[i]
    for j in range(i+1, n-1):
        b = lis[j]
        tmp = bisect_left(lis, a+b)
        
        cnt += tmp - 1 -j
    

print(cnt)