from bisect import bisect_left, bisect_right



N = int(eval(input()))

Ls = list(map(int, input().split()))



Ls.sort()

#print(Ls)



ans = 0

for i in range(N):

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

        k = bisect_left(Ls, Ls[i]+Ls[j])

        ans += k-j-1

print(ans)

from bisect import bisect_left, bisect_right



def solve():

    N = int(eval(input()))

    Ls = list(map(int, input().split()))



    Ls.sort()



    ans = 0

    for i in range(N):

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

            k = bisect_left(Ls, Ls[i]+Ls[j]) - 1

            ans += k-j



    print(ans)





solve()

from bisect import bisect_left, bisect_right

N = int(eval(input()))
Ls = list(map(int, input().split()))
Ls.sort()
# print(Ls)
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        k = bisect_left(Ls, Ls[i] + Ls[j])
        ans += k - j - 1
print(ans)

from bisect import bisect_left, bisect_right


def solve():
    N = int(eval(input()))
    Ls = list(map(int, input().split()))
    Ls.sort()
    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            k = bisect_left(Ls, Ls[i] + Ls[j]) - 1
            ans += k - j
    print(ans)


solve()

-N = int(eval(input())) -Ls = list(map(int, input().split())) -Ls.sort() -# print(Ls) -ans = 0 -for i in range(N): -    for j in range(i + 1, N): -        k = bisect_left(Ls, Ls[i] + Ls[j]) -        ans += k - j - 1 -print(ans) + +def solve(): +    N = int(eval(input())) +    Ls = list(map(int, input().split())) +    Ls.sort() +    ans = 0 +    for i in range(N): +        for j in range(i + 1, N): +            k = bisect_left(Ls, Ls[i] + Ls[j]) - 1 +            ans += k - j +    print(ans) + + +solve()