import bisect
n = int(input())
l = list(map(int, input().split()))
sort_l = sorted(l)
count = 0

for a in range(n):
    for b in range(a+1, n):
        c = bisect.bisect_left(sort_l, sort_l[a] + sort_l[b])
        if c > b:
            count += c - b -1
        else:
            pass     
        

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 sort_l = sorted(l) sort_l sorted(l) sorted l count = 0 count 0 for a in range(n):
    for b in range(a+1, n):
        c = bisect.bisect_left(sort_l, sort_l[a] + sort_l[b])
        if c > b:
            count += c - b -1
        else:
            pass     
         a range(n) range n for b in range(a+1, n):
        c = bisect.bisect_left(sort_l, sort_l[a] + sort_l[b])
        if c > b:
            count += c - b -1
        else:
            pass     
         b range(a+1, n) range a+1 a 1 n c = bisect.bisect_left(sort_l, sort_l[a] + sort_l[b]) c bisect.bisect_left(sort_l, sort_l[a] + sort_l[b]) bisect.bisect_left bisect bisect_left sort_l sort_l[a] + sort_l[b] sort_l[a] sort_l a sort_l[b] sort_l b if c > b:
            count += c - b -1
        else:
            pass     
         c > b c b count += c - b -1 count c - b -1 c - b c b 1 print(count) print count n = int(input()) int(input()) n c = bisect.bisect_left(sort_l, sort_l[a] + sort_l[b]) bisect.bisect_left(sort_l, sort_l[a] + sort_l[b]) c count += c - b -1 c - b -1 count sort_l = sorted(l) sorted(l) sort_l count = 0 0 count l = list(map(int, input().split())) list(map(int, input().split())) l
import bisect
n = int(input())
l = list(map(int, input().split()))
sort_l = sorted(l)
count = 0

for a in range(n):
    for b in range(a+1, n):
        c = bisect.bisect_left(sort_l, sort_l[a] + sort_l[b])
        if c > b:
            count += c - b -1
        else:
            pass     
        

print(count)