import bisect



N = int(eval(input()))

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

L.sort()



ans = 0

# a <= b <= c



for b in range(1,N-1):

  for c in range(b+1,N):

    # search min(c) with a + b > c <=> a > c - b

    idx = bisect.bisect_left(L[:b],L[c]-L[b]+1)

    #print(L[b],L[c],idx)

    ans += max(b-idx,0) if idx >= 0 else 0 

    #print(idx, ans)

#print(L)

print(ans)
import bisect



N = int(eval(input()))

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

L.sort()



ans = 0

# a <= b <= c



for b in range(1,N-1):

  for c in range(b+1,N):

    # search min(c) with a + b > c <=> a > c - b

    idx = bisect.bisect_left(L,L[c]-L[b]+1)

    #print(L[b],L[c],idx)

    ans += max(b-idx,0) if idx >= 0 else 0 

    #print(idx, ans)

#print(L)

print(ans)
import bisect

N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
# a <= b <= c
for b in range(1, N - 1):
    for c in range(b + 1, N):
        # search min(c) with a + b > c <=> a > c - b
        idx = bisect.bisect_left(L[:b], L[c] - L[b] + 1)
        # print(L[b],L[c],idx)
        ans += max(b - idx, 0) if idx >= 0 else 0
        # print(idx, ans)
# print(L)
print(ans)

import bisect

N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
# a <= b <= c
for b in range(1, N - 1):
    for c in range(b + 1, N):
        # search min(c) with a + b > c <=> a > c - b
        idx = bisect.bisect_left(L, L[c] - L[b] + 1)
        # print(L[b],L[c],idx)
        ans += max(b - idx, 0) if idx >= 0 else 0
        # print(idx, ans)
# print(L)
print(ans)

-        idx = bisect.bisect_left(L[:b], L[c] - L[b] + 1) +        idx = bisect.bisect_left(L, L[c] - L[b] + 1)