import bisect
N = int(input())
L = list(map(int, input().split()))
count = 0

L.sort()

for i in range(N-2):
    for j in range(i+1,N-1):
        k = bisect.bisect_left(L,L[i]+L[j])
        count += k-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 count = 0 count 0 L.sort() L.sort L sort for i in range(N-2):
    for j in range(i+1,N-1):
        k = bisect.bisect_left(L,L[i]+L[j])
        count += k-j-1 i range(N-2) range N-2 N 2 for j in range(i+1,N-1):
        k = bisect.bisect_left(L,L[i]+L[j])
        count += k-j-1 j range(i+1,N-1) range i+1 i 1 N-1 N 1 k = bisect.bisect_left(L,L[i]+L[j]) k 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 count += k-j-1 count k-j-1 k-j k j 1 print(count) print count k = bisect.bisect_left(L,L[i]+L[j]) bisect.bisect_left(L,L[i]+L[j]) k count += k-j-1 k-j-1 count N = int(input()) int(input()) N 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()))
count = 0

L.sort()

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

print(count)