import bisect

from itertools import combinations



def main():

    N = int(eval(input()))

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

    ans = 0

    for l in combinations(L, 2):

        a = l[0]

        b = l[1]

        x = bisect.bisect_left(L, a + b)

        y = bisect.bisect(L, b - a)

        if b - a < a :

            ans += x - y - 2

        else:

            ans += x - y - 1

    print((ans // 3))





if __name__ == "__main__":

    main()

import bisect

from copy import deepcopy

N = int(eval(input()))

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



ans = 0

for i in range(N):

    for j in range(i + 1, N - 1):

        b = L[j] + L[i]

        x = bisect.bisect_left(L, b) - j - 1

        if x > 0:

            ans += x



print(ans)

import bisect
from itertools import combinations


def main():
    N = int(eval(input()))
    L = sorted(list(map(int, input().split())))
    ans = 0
    for l in combinations(L, 2):
        a = l[0]
        b = l[1]
        x = bisect.bisect_left(L, a + b)
        y = bisect.bisect(L, b - a)
        if b - a < a:
            ans += x - y - 2
        else:
            ans += x - y - 1
    print((ans // 3))


if __name__ == "__main__":
    main()

import bisect
from copy import deepcopy

N = int(eval(input()))
L = sorted(map(int, input().split()))
ans = 0
for i in range(N):
    for j in range(i + 1, N - 1):
        b = L[j] + L[i]
        x = bisect.bisect_left(L, b) - j - 1
        if x > 0:
            ans += x
print(ans)

-from itertools import combinations +from copy import deepcopy - -def main(): -    N = int(eval(input())) -    L = sorted(list(map(int, input().split()))) -    ans = 0 -    for l in combinations(L, 2): -        a = l[0] -        b = l[1] -        x = bisect.bisect_left(L, a + b) -        y = bisect.bisect(L, b - a) -        if b - a < a: -            ans += x - y - 2 -        else: -            ans += x - y - 1 -    print((ans // 3)) - - -if __name__ == "__main__": -    main() +N = int(eval(input())) +L = sorted(map(int, input().split())) +ans = 0 +for i in range(N): +    for j in range(i + 1, N - 1): +        b = L[j] + L[i] +        x = bisect.bisect_left(L, b) - j - 1 +        if x > 0: +            ans += x +print(ans)