N = int(eval(input()))

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



L.sort()



import bisect

ans = 0



for i in range(N-2):

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

        a = L[i] 

        b = L[j] 

        

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

        #print(insert_index,a,b,a+b)

        

        if i < insert_index:

            ans += insert_index - j - 1

            #print(i,j,insert_index)

        

print(ans)
N = int(eval(input()))

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



import bisect

ans = 0



L.sort()

for i in range(0,N-2):

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

        a = L[i]

        b = L[j]

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

        if index > j:

            ans += index-j-1

            

print(ans)
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
import bisect

ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        a = L[i]
        b = L[j]
        insert_index = bisect.bisect_left(L, a + b)
        # print(insert_index,a,b,a+b)
        if i < insert_index:
            ans += insert_index - j - 1
            # print(i,j,insert_index)
print(ans)

N = int(eval(input()))
L = list(map(int, input().split()))
import bisect

ans = 0
L.sort()
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        a = L[i]
        b = L[j]
        index = bisect.bisect_left(L, a + b)
        if index > j:
            ans += index - j - 1
print(ans)

-L.sort() -for i in range(N - 2): +L.sort() +for i in range(0, N - 2): -        insert_index = bisect.bisect_left(L, a + b) -        # print(insert_index,a,b,a+b) -        if i < insert_index: -            ans += insert_index - j - 1 -            # print(i,j,insert_index) +        index = bisect.bisect_left(L, a + b) +        if index > j: +            ans += index - j - 1