from bisect import bisect_left
n, *l = map(int, open(0).read().split())
l.sort()

ans = 0
for i in range(n):
    for j in range(i + 1, n):
        ng = n - bisect_left(l, l[i] + l[j]) + 1
        ans += (n - j) - ng
print(ans) from bisect import bisect_left n, *l = map(int, open(0).read().split()) n map(int, open(0).read().split()) map int open(0).read().split() (0).read().split (0).read() (0).read (0) open 0 read split *l l l.sort() l.sort l sort ans = 0 ans 0 for i in range(n):
    for j in range(i + 1, n):
        ng = n - bisect_left(l, l[i] + l[j]) + 1
        ans += (n - j) - ng i range(n) range n for j in range(i + 1, n):
        ng = n - bisect_left(l, l[i] + l[j]) + 1
        ans += (n - j) - ng j range(i + 1, n) range i + 1 i 1 n ng = n - bisect_left(l, l[i] + l[j]) + 1 ng n - bisect_left(l, l[i] + l[j]) + 1 n - bisect_left(l, l[i] + l[j]) n bisect_left(l, l[i] + l[j]) bisect_left l l[i] + l[j] l[i] l i l[j] l j 1 ans += (n - j) - ng ans (n - j) - ng n - j n j ng print(ans) print ans n, *l = map(int, open(0).read().split()) map(int, open(0).read().split()) n ans += (n - j) - ng (n - j) - ng ans ans = 0 0 ans ng = n - bisect_left(l, l[i] + l[j]) + 1 n - bisect_left(l, l[i] + l[j]) + 1 ng
from bisect import bisect_left
n, *l = map(int, open(0).read().split())
l.sort()

ans = 0
for i in range(n):
    for j in range(i + 1, n):
        ng = n - bisect_left(l, l[i] + l[j]) + 1
        ans += (n - j) - ng
print(ans)
