from itertools import accumulate, combinations



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



A = [0] * (2 * 10 ** 3 + 7)

for l in L:

    A[l] += 1



S = list(accumulate(A))



ans = 0

for b, c in combinations(L, 2):

    l, r = abs(b - c), b + c

    ans += S[r - 1] - S[l] - (l < b < r) - (l < c < r)



print((ans // 3))

from itertools import accumulate, combinations



def main():

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



    A = [0] * (2 * 10 ** 3 + 7)

    for l in L:

        A[l] += 1



    S = list(accumulate(A))



    ans = 0

    for b, c in combinations(L, 2):

        l, r = c - b if c > b else b - c, b + c

        ans += S[r - 1] - S[l] - (l < b < r) - (l < c < r)



    print((ans // 3))



if __name__ == '__main__':

    main()

from itertools import accumulate, combinations

N, *L = list(map(int, open(0).read().split()))
A = [0] * (2 * 10**3 + 7)
for l in L:
    A[l] += 1
S = list(accumulate(A))
ans = 0
for b, c in combinations(L, 2):
    l, r = abs(b - c), b + c
    ans += S[r - 1] - S[l] - (l < b < r) - (l < c < r)
print((ans // 3))

from itertools import accumulate, combinations


def main():
    N, *L = list(map(int, open(0).read().split()))
    A = [0] * (2 * 10**3 + 7)
    for l in L:
        A[l] += 1
    S = list(accumulate(A))
    ans = 0
    for b, c in combinations(L, 2):
        l, r = c - b if c > b else b - c, b + c
        ans += S[r - 1] - S[l] - (l < b < r) - (l < c < r)
    print((ans // 3))


if __name__ == "__main__":
    main()

-N, *L = list(map(int, open(0).read().split())) -A = [0] * (2 * 10**3 + 7) -for l in L: -    A[l] += 1 -S = list(accumulate(A)) -ans = 0 -for b, c in combinations(L, 2): -    l, r = abs(b - c), b + c -    ans += S[r - 1] - S[l] - (l < b < r) - (l < c < r) -print((ans // 3)) + +def main(): +    N, *L = list(map(int, open(0).read().split())) +    A = [0] * (2 * 10**3 + 7) +    for l in L: +        A[l] += 1 +    S = list(accumulate(A)) +    ans = 0 +    for b, c in combinations(L, 2): +        l, r = c - b if c > b else b - c, b + c +        ans += S[r - 1] - S[l] - (l < b < r) - (l < c < r) +    print((ans // 3)) + + +if __name__ == "__main__": +    main()