from bisect import bisect_left, bisect_right

N, *X = map(int, open(0).read().split())

X.sort()
ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        k1 = bisect_right(X, X[j] - X[i])
        k2 = bisect_left(X, X[i] + X[j])
        k1 = max(k1, j + 1)
        ans += max(0, k2 - k1)

print(ans) from bisect import bisect_left, bisect_right N, *X = 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 *X X X.sort() X.sort X sort ans = 0 ans 0 for i in range(N - 2):
    for j in range(i + 1, N - 1):
        k1 = bisect_right(X, X[j] - X[i])
        k2 = bisect_left(X, X[i] + X[j])
        k1 = max(k1, j + 1)
        ans += max(0, k2 - k1) i range(N - 2) range N - 2 N 2 for j in range(i + 1, N - 1):
        k1 = bisect_right(X, X[j] - X[i])
        k2 = bisect_left(X, X[i] + X[j])
        k1 = max(k1, j + 1)
        ans += max(0, k2 - k1) j range(i + 1, N - 1) range i + 1 i 1 N - 1 N 1 k1 = bisect_right(X, X[j] - X[i]) k1 bisect_right(X, X[j] - X[i]) bisect_right X X[j] - X[i] X[j] X j X[i] X i k2 = bisect_left(X, X[i] + X[j]) k2 bisect_left(X, X[i] + X[j]) bisect_left X X[i] + X[j] X[i] X i X[j] X j k1 = max(k1, j + 1) k1 max(k1, j + 1) max k1 j + 1 j 1 ans += max(0, k2 - k1) ans max(0, k2 - k1) max 0 k2 - k1 k2 k1 print(ans) print ans ans = 0 0 ans k1 = bisect_right(X, X[j] - X[i]) bisect_right(X, X[j] - X[i]) k1 k1 = max(k1, j + 1) max(k1, j + 1) k1 ans += max(0, k2 - k1) max(0, k2 - k1) ans k2 = bisect_left(X, X[i] + X[j]) bisect_left(X, X[i] + X[j]) k2 N, *X = map(int, open(0).read().split()) map(int, open(0).read().split()) N
from bisect import bisect_left, bisect_right

N, *X = map(int, open(0).read().split())

X.sort()
ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        k1 = bisect_right(X, X[j] - X[i])
        k2 = bisect_left(X, X[i] + X[j])
        k1 = max(k1, j + 1)
        ans += max(0, k2 - k1)

print(ans)
