import bisect
n = int(input())
l_li = list(map(int,input().split()))
l_li.sort()
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        ind = bisect.bisect_left(l_li,l_li[i]+l_li[j])
        num = ind-1 - j
        if num > 0:
            ans += num
print(ans) import bisect bisect n = int(input()) n int(input()) int input() input l_li = list(map(int,input().split())) l_li list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split l_li.sort() l_li.sort l_li sort ans = 0 ans 0 for i in range(n-2):
    for j in range(i+1,n-1):
        ind = bisect.bisect_left(l_li,l_li[i]+l_li[j])
        num = ind-1 - j
        if num > 0:
            ans += num i range(n-2) range n-2 n 2 for j in range(i+1,n-1):
        ind = bisect.bisect_left(l_li,l_li[i]+l_li[j])
        num = ind-1 - j
        if num > 0:
            ans += num j range(i+1,n-1) range i+1 i 1 n-1 n 1 ind = bisect.bisect_left(l_li,l_li[i]+l_li[j]) ind bisect.bisect_left(l_li,l_li[i]+l_li[j]) bisect.bisect_left bisect bisect_left l_li l_li[i]+l_li[j] l_li[i] l_li i l_li[j] l_li j num = ind-1 - j num ind-1 - j ind-1 ind 1 j if num > 0:
            ans += num num > 0 num 0 ans += num ans num print(ans) print ans num = ind-1 - j ind-1 - j num l_li = list(map(int,input().split())) list(map(int,input().split())) l_li ans += num num ans n = int(input()) int(input()) n ans = 0 0 ans ind = bisect.bisect_left(l_li,l_li[i]+l_li[j]) bisect.bisect_left(l_li,l_li[i]+l_li[j]) ind
import bisect
n = int(input())
l_li = list(map(int,input().split()))
l_li.sort()
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        ind = bisect.bisect_left(l_li,l_li[i]+l_li[j])
        num = ind-1 - j
        if num > 0:
            ans += num
print(ans)
