#!/usr/bin/env python3
from bisect import bisect_right

n, *L = map(int, open(0).read().split())
L.sort()
ans = 0
c = [0] * (2 * 10**3 + 1)
for i in range(2 * 10**3 + 1):
    c[i] = bisect_right(L, i)
for i in range(n):
    for j in range(i + 1, n):
        ans += c[L[i] + L[j] - 1] - c[L[j] - L[i]] - 1 - (L[j] - L[i]*2 < 0)
print(ans//3) from bisect import bisect_right 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 c = [0] * (2 * 10**3 + 1) c [0] * (2 * 10**3 + 1) [0] 0 2 * 10**3 + 1 2 * 10**3 2 10**3 10 3 1 for i in range(2 * 10**3 + 1):
    c[i] = bisect_right(L, i) i range(2 * 10**3 + 1) range 2 * 10**3 + 1 2 * 10**3 2 10**3 10 3 1 c[i] = bisect_right(L, i) c[i] c i bisect_right(L, i) bisect_right L i for i in range(n):
    for j in range(i + 1, n):
        ans += c[L[i] + L[j] - 1] - c[L[j] - L[i]] - 1 - (L[j] - L[i]*2 < 0) i range(n) range n for j in range(i + 1, n):
        ans += c[L[i] + L[j] - 1] - c[L[j] - L[i]] - 1 - (L[j] - L[i]*2 < 0) j range(i + 1, n) range i + 1 i 1 n ans += c[L[i] + L[j] - 1] - c[L[j] - L[i]] - 1 - (L[j] - L[i]*2 < 0) ans c[L[i] + L[j] - 1] - c[L[j] - L[i]] - 1 - (L[j] - L[i]*2 < 0) c[L[i] + L[j] - 1] - c[L[j] - L[i]] - 1 c[L[i] + L[j] - 1] - c[L[j] - L[i]] c[L[i] + L[j] - 1] c L[i] + L[j] - 1 L[i] + L[j] L[i] L i L[j] L j 1 c[L[j] - L[i]] c L[j] - L[i] L[j] L j L[i] L i 1 L[j] - L[i]*2 < 0 L[j] - L[i]*2 L[j] L j L[i]*2 L[i] L i 2 0 print(ans//3) print ans//3 ans 3 n, *L = map(int, open(0).read().split()) map(int, open(0).read().split()) n ans = 0 0 ans c = [0] * (2 * 10**3 + 1) [0] * (2 * 10**3 + 1) c ans += c[L[i] + L[j] - 1] - c[L[j] - L[i]] - 1 - (L[j] - L[i]*2 < 0) c[L[i] + L[j] - 1] - c[L[j] - L[i]] - 1 - (L[j] - L[i]*2 < 0) ans
#!/usr/bin/env python3
from bisect import bisect_right

n, *L = map(int, open(0).read().split())
L.sort()
ans = 0
c = [0] * (2 * 10**3 + 1)
for i in range(2 * 10**3 + 1):
    c[i] = bisect_right(L, i)
for i in range(n):
    for j in range(i + 1, n):
        ans += c[L[i] + L[j] - 1] - c[L[j] - L[i]] - 1 - (L[j] - L[i]*2 < 0)
print(ans//3)
