from collections import deque
from bisect import bisect_left

n = int(input())
l = sorted(map(int, input().split()))
ld = deque(l)
cnt = 0
for a in range(n - 2):
    l_a = ld.popleft()
    for b in range(a + 1, n - 1):
        cnt += bisect_left(l, l_a + l[b]) - b - 1
print(cnt) from collections import deque from bisect import bisect_left n = int(input()) n int(input()) int input() input l = sorted(map(int, input().split())) l sorted(map(int, input().split())) sorted map(int, input().split()) map int input().split() ().split () input split ld = deque(l) ld deque(l) deque l cnt = 0 cnt 0 for a in range(n - 2):
    l_a = ld.popleft()
    for b in range(a + 1, n - 1):
        cnt += bisect_left(l, l_a + l[b]) - b - 1 a range(n - 2) range n - 2 n 2 l_a = ld.popleft() l_a ld.popleft() ld.popleft ld popleft for b in range(a + 1, n - 1):
        cnt += bisect_left(l, l_a + l[b]) - b - 1 b range(a + 1, n - 1) range a + 1 a 1 n - 1 n 1 cnt += bisect_left(l, l_a + l[b]) - b - 1 cnt bisect_left(l, l_a + l[b]) - b - 1 bisect_left(l, l_a + l[b]) - b bisect_left(l, l_a + l[b]) bisect_left l l_a + l[b] l_a l[b] l b b 1 print(cnt) print cnt n = int(input()) int(input()) n l = sorted(map(int, input().split())) sorted(map(int, input().split())) l cnt += bisect_left(l, l_a + l[b]) - b - 1 bisect_left(l, l_a + l[b]) - b - 1 cnt ld = deque(l) deque(l) ld cnt = 0 0 cnt l_a = ld.popleft() ld.popleft() l_a
from collections import deque
from bisect import bisect_left

n = int(input())
l = sorted(map(int, input().split()))
ld = deque(l)
cnt = 0
for a in range(n - 2):
    l_a = ld.popleft()
    for b in range(a + 1, n - 1):
        cnt += bisect_left(l, l_a + l[b]) - b - 1
print(cnt)