from bisect import *

if __name__ == '__main__':

    N = int(eval(input()))

    L = sorted(map(int, input().split()))

    print((sum(jdx - bisect(L, a - L[jdx], 0, jdx) for idx, a in enumerate(L) for jdx in range(idx))))
if __name__ == '__main__':

    N = int(eval(input()))

    L = sorted(map(int, input().split()))

    ret = 0

    for adx in range(N):

        cdx = adx

        for bdx in range(adx + 1, N):

            while cdx < N and L[cdx] < L[bdx] + L[adx]: cdx += 1

            ret += cdx - (bdx + 1)

    print(ret)
from bisect import *

if __name__ == "__main__":
    N = int(eval(input()))
    L = sorted(map(int, input().split()))
    print(
        (
            sum(
                jdx - bisect(L, a - L[jdx], 0, jdx)
                for idx, a in enumerate(L)
                for jdx in range(idx)
            )
        )
    )

if __name__ == "__main__":
    N = int(eval(input()))
    L = sorted(map(int, input().split()))
    ret = 0
    for adx in range(N):
        cdx = adx
        for bdx in range(adx + 1, N):
            while cdx < N and L[cdx] < L[bdx] + L[adx]:
                cdx += 1
            ret += cdx - (bdx + 1)
    print(ret)

-from bisect import * - -    print( -        ( -            sum( -                jdx - bisect(L, a - L[jdx], 0, jdx) -                for idx, a in enumerate(L) -                for jdx in range(idx) -            ) -        ) -    ) +    ret = 0 +    for adx in range(N): +        cdx = adx +        for bdx in range(adx + 1, N): +            while cdx < N and L[cdx] < L[bdx] + L[adx]: +                cdx += 1 +            ret += cdx - (bdx + 1) +    print(ret)