import bisect

N = int(input())
l = list(map(int, input().split()))
l.sort()
count = 0

for i in range(N):
    for j in range(i+1, N):
        count += bisect.bisect_left(l, l[i]+l[j])-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):
    for j in range(i+1, N):
        count += bisect.bisect_left(l, l[i]+l[j])-j-1 i range(N) range N for j in range(i+1, N):
        count += bisect.bisect_left(l, l[i]+l[j])-j-1 j range(i+1, N) range i+1 i 1 N count += bisect.bisect_left(l, l[i]+l[j])-j-1 count bisect.bisect_left(l, l[i]+l[j])-j-1 bisect.bisect_left(l, l[i]+l[j])-j bisect.bisect_left(l, l[i]+l[j]) bisect.bisect_left bisect bisect_left l l[i]+l[j] l[i] l i l[j] l j j 1 print(count) print count count += bisect.bisect_left(l, l[i]+l[j])-j-1 bisect.bisect_left(l, l[i]+l[j])-j-1 count l = list(map(int, input().split())) list(map(int, input().split())) l N = int(input()) int(input()) N count = 0 0 count
import bisect

N = int(input())
l = list(map(int, input().split()))
l.sort()
count = 0

for i in range(N):
    for j in range(i+1, N):
        count += bisect.bisect_left(l, l[i]+l[j])-j-1
print(count)
