N=int(eval(input()))

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

S = sorted(S)

tri_num=0

for i in range(N-2):

    k = i+2

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

        while k < N:

            if S[i] + S[j] <= S[k]:

                tri_num = tri_num + k-j-1

                if k == i+2:

                    k+=1

                break

            if k == N-1:

                tri_num = tri_num + k-j

                break

            k+=1

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

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

S = sorted(S,reverse=True)

tri_num=0

for i in range(N-2):

    j = i+1

    k = N-1

    while k > j:

        if S[i] < S[j] + S[k]:

            tri_num += k-j

            j+=1

        else:

            k-=1

print(tri_num)

N = int(eval(input()))
S = list(map(int, input().split()))
S = sorted(S)
tri_num = 0
for i in range(N - 2):
    k = i + 2
    for j in range(i + 1, N - 1):
        while k < N:
            if S[i] + S[j] <= S[k]:
                tri_num = tri_num + k - j - 1
                if k == i + 2:
                    k += 1
                break
            if k == N - 1:
                tri_num = tri_num + k - j
                break
            k += 1
print(tri_num)

N = int(eval(input()))
S = list(map(int, input().split()))
S = sorted(S, reverse=True)
tri_num = 0
for i in range(N - 2):
    j = i + 1
    k = N - 1
    while k > j:
        if S[i] < S[j] + S[k]:
            tri_num += k - j
            j += 1
        else:
            k -= 1
print(tri_num)

-S = sorted(S) +S = sorted(S, reverse=True) -    k = i + 2 -    for j in range(i + 1, N - 1): -        while k < N: -            if S[i] + S[j] <= S[k]: -                tri_num = tri_num + k - j - 1 -                if k == i + 2: -                    k += 1 -                break -            if k == N - 1: -                tri_num = tri_num + k - j -                break -            k += 1 +    j = i + 1 +    k = N - 1 +    while k > j: +        if S[i] < S[j] + S[k]: +            tri_num += k - j +            j += 1 +        else: +            k -= 1