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

