from bisect import bisect_left, bisect_right

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

n = int(input())
l = list(map(int, input().split()))
l.sort()
pattern = 0
for i in range(n - 2):
    a = l[i]
    for j in range(i + 1, n - 1):
        b = l[j]
        c_idx = bisect_left(l, a + b)
        pattern += (c_idx - j - 1)
print(pattern)
