from bisect import bisect_left, bisect_right

n = int(input())
stick = list(map(int, input().split()))
stick.sort()

count = 0
for i in range(n):
    for j in range(i + 1, n):
        l = bisect_right(stick, stick[j] - stick[i])
        r = bisect_left(stick, stick[i] + stick[j]) # [l, r) が範囲
        if j + 1 >= r:
            continue
        count += r - max(l, j + 1)
print(count) from bisect import bisect_left, bisect_right n = int(input()) n int(input()) int input() input stick = list(map(int, input().split())) stick list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split stick.sort() stick.sort stick sort count = 0 count 0 for i in range(n):
    for j in range(i + 1, n):
        l = bisect_right(stick, stick[j] - stick[i])
        r = bisect_left(stick, stick[i] + stick[j]) # [l, r) が範囲
        if j + 1 >= r:
            continue
        count += r - max(l, j + 1) i range(n) range n for j in range(i + 1, n):
        l = bisect_right(stick, stick[j] - stick[i])
        r = bisect_left(stick, stick[i] + stick[j]) # [l, r) が範囲
        if j + 1 >= r:
            continue
        count += r - max(l, j + 1) j range(i + 1, n) range i + 1 i 1 n l = bisect_right(stick, stick[j] - stick[i]) l bisect_right(stick, stick[j] - stick[i]) bisect_right stick stick[j] - stick[i] stick[j] stick j stick[i] stick i r = bisect_left(stick, stick[i] + stick[j]) r bisect_left(stick, stick[i] + stick[j]) bisect_left stick stick[i] + stick[j] stick[i] stick i stick[j] stick j if j + 1 >= r:
            continue
         j + 1 >= r j + 1 j 1 r continue count += r - max(l, j + 1) count r - max(l, j + 1) r max(l, j + 1) max l j + 1 j 1 print(count) print count stick = list(map(int, input().split())) list(map(int, input().split())) stick l = bisect_right(stick, stick[j] - stick[i]) bisect_right(stick, stick[j] - stick[i]) l count = 0 0 count count += r - max(l, j + 1) r - max(l, j + 1) count n = int(input()) int(input()) n r = bisect_left(stick, stick[i] + stick[j]) bisect_left(stick, stick[i] + stick[j]) r
from bisect import bisect_left, bisect_right

n = int(input())
stick = list(map(int, input().split()))
stick.sort()

count = 0
for i in range(n):
    for j in range(i + 1, n):
        l = bisect_right(stick, stick[j] - stick[i])
        r = bisect_left(stick, stick[i] + stick[j]) # [l, r) が範囲
        if j + 1 >= r:
            continue
        count += r - max(l, j + 1)
print(count)