from bisect import *

n = int(input())
l = sorted(list(map(int, input().split())))

cnt = 0

for i in range(n):
    a = l[i]
    for j in range(i+1, n):
        b = l[j]
        k = bisect_left(l, a+b)
        cnt += k-(j+1)
print(cnt) from bisect import * n = int(input()) n int(input()) int input() input l = sorted(list(map(int, input().split()))) l sorted(list(map(int, input().split()))) sorted list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split cnt = 0 cnt 0 for i in range(n):
    a = l[i]
    for j in range(i+1, n):
        b = l[j]
        k = bisect_left(l, a+b)
        cnt += k-(j+1) i range(n) range n a = l[i] a l[i] l i for j in range(i+1, n):
        b = l[j]
        k = bisect_left(l, a+b)
        cnt += k-(j+1) j range(i+1, n) range i+1 i 1 n b = l[j] b l[j] l j k = bisect_left(l, a+b) k bisect_left(l, a+b) bisect_left l a+b a b cnt += k-(j+1) cnt k-(j+1) k j+1 j 1 print(cnt) print cnt cnt += k-(j+1) k-(j+1) cnt n = int(input()) int(input()) n k = bisect_left(l, a+b) bisect_left(l, a+b) k a = l[i] l[i] a b = l[j] l[j] b cnt = 0 0 cnt l = sorted(list(map(int, input().split()))) sorted(list(map(int, input().split()))) l
from bisect import *

n = int(input())
l = sorted(list(map(int, input().split())))

cnt = 0

for i in range(n):
    a = l[i]
    for j in range(i+1, n):
        b = l[j]
        k = bisect_left(l, a+b)
        cnt += k-(j+1)
print(cnt)