import bisect
n = int(input())
l = list(map(int,input().split()))
l.sort()
count = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        maxc = l[i]+l[j] #短い2辺の和
        index = bisect.bisect_left(l, maxc)
        if index > j:
            count += index-j-1
print(count) 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 count = 0 count 0 for i in range(n-2):
    for j in range(i+1,n-1):
        maxc = l[i]+l[j] #短い2辺の和
        index = bisect.bisect_left(l, maxc)
        if index > j:
            count += index-j-1 i range(n-2) range n-2 n 2 for j in range(i+1,n-1):
        maxc = l[i]+l[j] #短い2辺の和
        index = bisect.bisect_left(l, maxc)
        if index > j:
            count += index-j-1 j range(i+1,n-1) range i+1 i 1 n-1 n 1 maxc = l[i]+l[j] maxc l[i]+l[j] l[i] l i l[j] l j index = bisect.bisect_left(l, maxc) index bisect.bisect_left(l, maxc) bisect.bisect_left bisect bisect_left l maxc if index > j:
            count += index-j-1 index > j index j count += index-j-1 count index-j-1 index-j index j 1 print(count) print count count += index-j-1 index-j-1 count n = int(input()) int(input()) n count = 0 0 count maxc = l[i]+l[j] l[i]+l[j] maxc l = list(map(int,input().split())) list(map(int,input().split())) l index = bisect.bisect_left(l, maxc) bisect.bisect_left(l, maxc) index
import bisect
n = int(input())
l = list(map(int,input().split()))
l.sort()
count = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        maxc = l[i]+l[j] #短い2辺の和
        index = bisect.bisect_left(l, maxc)
        if index > j:
            count += index-j-1
print(count)