import bisect



N = eval(input())

N = int(N)

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



L_sorted = sorted(L, reverse = False)#昇順



count = 0

for i in range(N):#aの選び方

    for j in range(i+1,N):#bの選び方

        a = L_sorted[i]

        b = L_sorted[j]#b <= c < a+b

        count += bisect.bisect_left(L_sorted, a+b) - j -1

print(count)
import bisect

N = int(eval(input()))

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

L = sorted(L,reverse = False)



cnt = 0

# a の index

for a in range(len(L)):

    # b の index

    for b in range(a+1,len(L)):

        # c が取りうる最大の index

        c_idx = bisect.bisect_left(L,L[a]+L[b]) - 1

        cnt += c_idx - b

print(cnt)
import bisect

N = eval(input())
N = int(N)
L = list(map(int, input().split()))
L_sorted = sorted(L, reverse=False)  # 昇順
count = 0
for i in range(N):  # aの選び方
    for j in range(i + 1, N):  # bの選び方
        a = L_sorted[i]
        b = L_sorted[j]  # b <= c < a+b
        count += bisect.bisect_left(L_sorted, a + b) - j - 1
print(count)

import bisect

N = int(eval(input()))
L = list(map(int, input().split()))
L = sorted(L, reverse=False)
cnt = 0
# a の index
for a in range(len(L)):
    # b の index
    for b in range(a + 1, len(L)):
        # c が取りうる最大の index
        c_idx = bisect.bisect_left(L, L[a] + L[b]) - 1
        cnt += c_idx - b
print(cnt)

-N = eval(input()) -N = int(N) +N = int(eval(input())) -L_sorted = sorted(L, reverse=False)  # 昇順 -count = 0 -for i in range(N):  # aの選び方 -    for j in range(i + 1, N):  # bの選び方 -        a = L_sorted[i] -        b = L_sorted[j]  # b <= c < a+b -        count += bisect.bisect_left(L_sorted, a + b) - j - 1 -print(count) +L = sorted(L, reverse=False) +cnt = 0 +# a の index +for a in range(len(L)): +    # b の index +    for b in range(a + 1, len(L)): +        # c が取りうる最大の index +        c_idx = bisect.bisect_left(L, L[a] + L[b]) - 1 +        cnt += c_idx - b +print(cnt)