from bisect import bisect_left
n = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0

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

for i in range(n):
    for j in range(i+1, n):
        ans += bisect_left(L, L[i]+L[j])-j-1
print(ans)
