import bisect
n = int(input())
l = list(map(int, input().split()))

l.sort()

ans = 0
for a in range(0, n-2):
    for b in range(a+1, n-1):
        c = l[a] + l[b]
        ans += bisect.bisect_left(l, c) - b - 1

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

l.sort()

ans = 0
for a in range(0, n-2):
    for b in range(a+1, n-1):
        c = l[a] + l[b]
        ans += bisect.bisect_left(l, c) - b - 1

print(ans)