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

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

cnt = 0
for a in range(n-2):
    for b in range(a+1, n-1):
        cnt += bisect_left(L,L[a]+L[b])-(b+1)
print(cnt)