from bisect import bisect_left, bisect_right
from collections import Counter
N = int(input())
L = list(map(int, input().split()))
L.sort()
m = Counter(L)

ans = 0
for i, x in enumerate(L[:-2]):
    for j, y in enumerate(L[i+1:-1]):
        ans += bisect_left(L, x+y) - (i+j+2)
print(ans) from bisect import bisect_left, bisect_right from collections import Counter 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 m = Counter(L) m Counter(L) Counter L ans = 0 ans 0 for i, x in enumerate(L[:-2]):
    for j, y in enumerate(L[i+1:-1]):
        ans += bisect_left(L, x+y) - (i+j+2) i x enumerate(L[:-2]) enumerate L[:-2] L :-2 -2 for j, y in enumerate(L[i+1:-1]):
        ans += bisect_left(L, x+y) - (i+j+2) j y enumerate(L[i+1:-1]) enumerate L[i+1:-1] L i+1:-1 i+1 i 1 -1 ans += bisect_left(L, x+y) - (i+j+2) ans bisect_left(L, x+y) - (i+j+2) bisect_left(L, x+y) bisect_left L x+y x y i+j+2 i+j i j 2 print(ans) print ans N = int(input()) int(input()) N m = Counter(L) Counter(L) m L = list(map(int, input().split())) list(map(int, input().split())) L ans = 0 0 ans ans += bisect_left(L, x+y) - (i+j+2) bisect_left(L, x+y) - (i+j+2) ans
from bisect import bisect_left, bisect_right
from collections import Counter
N = int(input())
L = list(map(int, input().split()))
L.sort()
m = Counter(L)

ans = 0
for i, x in enumerate(L[:-2]):
    for j, y in enumerate(L[i+1:-1]):
        ans += bisect_left(L, x+y) - (i+j+2)
print(ans)