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 - 1, -1, -1):
    for j in range(i - 1, -1, -1):
        l = bisect_right(stick, stick[i] - stick[j])
        r = bisect_left(stick, stick[i] + stick[j]) # [l, r) が範囲
        if j <= l:
            break
        count += min(r, j) - l
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 - 1, -1, -1):
    for j in range(i - 1, -1, -1):
        l = bisect_right(stick, stick[i] - stick[j])
        r = bisect_left(stick, stick[i] + stick[j]) # [l, r) が範囲
        if j <= l:
            break
        count += min(r, j) - l i range(n - 1, -1, -1) range n - 1 n 1 -1 -1 for j in range(i - 1, -1, -1):
        l = bisect_right(stick, stick[i] - stick[j])
        r = bisect_left(stick, stick[i] + stick[j]) # [l, r) が範囲
        if j <= l:
            break
        count += min(r, j) - l j range(i - 1, -1, -1) range i - 1 i 1 -1 -1 l = bisect_right(stick, stick[i] - stick[j]) l bisect_right(stick, stick[i] - stick[j]) bisect_right stick stick[i] - stick[j] stick[i] stick i stick[j] stick j 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 <= l:
            break
         j <= l j l break count += min(r, j) - l count min(r, j) - l min(r, j) min r j l print(count) print count stick = list(map(int, input().split())) list(map(int, input().split())) stick l = bisect_right(stick, stick[i] - stick[j]) bisect_right(stick, stick[i] - stick[j]) l count = 0 0 count n = int(input()) int(input()) n r = bisect_left(stick, stick[i] + stick[j]) bisect_left(stick, stick[i] + stick[j]) r count += min(r, j) - l min(r, j) - l count
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 - 1, -1, -1):
    for j in range(i - 1, -1, -1):
        l = bisect_right(stick, stick[i] - stick[j])
        r = bisect_left(stick, stick[i] + stick[j]) # [l, r) が範囲
        if j <= l:
            break
        count += min(r, j) - l
print(count)

