from bisect import bisect_left

n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        k = l[i] + l[j]
        pos = bisect_left(l, k)
        ans += max(0, pos - j - 1)
print(ans) from bisect import bisect_left 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 i in range(n):
    for j in range(i + 1, n):
        k = l[i] + l[j]
        pos = bisect_left(l, k)
        ans += max(0, pos - j - 1) i range(n) range n for j in range(i + 1, n):
        k = l[i] + l[j]
        pos = bisect_left(l, k)
        ans += max(0, pos - j - 1) j range(i + 1, n) range i + 1 i 1 n k = l[i] + l[j] k l[i] + l[j] l[i] l i l[j] l j pos = bisect_left(l, k) pos bisect_left(l, k) bisect_left l k ans += max(0, pos - j - 1) ans max(0, pos - j - 1) max 0 pos - j - 1 pos - j pos j 1 print(ans) print ans k = l[i] + l[j] l[i] + l[j] k ans = 0 0 ans ans += max(0, pos - j - 1) max(0, pos - j - 1) ans n = int(input()) int(input()) n l = list(map(int, input().split())) list(map(int, input().split())) l pos = bisect_left(l, k) bisect_left(l, k) pos
from bisect import bisect_left

n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        k = l[i] + l[j]
        pos = bisect_left(l, k)
        ans += max(0, pos - j - 1)
print(ans)