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

L.sort()

# print(L)
import bisect
ans = 0
for i in range(N-2):
    l1 = L[i]
    for j in range(i+1, N-1):
        l2 = L[j]
        l3_max = (l1 + l2)

        k = bisect.bisect_left(L, l3_max, lo=j+1)
        ans += max(0, k - j - 1)
print(ans) N = int(input()) N int(input()) int input() input L = list(map(int, input().split())) L list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split L.sort() L.sort L sort import bisect bisect ans = 0 ans 0 for i in range(N-2):
    l1 = L[i]
    for j in range(i+1, N-1):
        l2 = L[j]
        l3_max = (l1 + l2)

        k = bisect.bisect_left(L, l3_max, lo=j+1)
        ans += max(0, k - j - 1) i range(N-2) range N-2 N 2 l1 = L[i] l1 L[i] L i for j in range(i+1, N-1):
        l2 = L[j]
        l3_max = (l1 + l2)

        k = bisect.bisect_left(L, l3_max, lo=j+1)
        ans += max(0, k - j - 1) j range(i+1, N-1) range i+1 i 1 N-1 N 1 l2 = L[j] l2 L[j] L j l3_max = (l1 + l2) l3_max l1 + l2 l1 l2 k = bisect.bisect_left(L, l3_max, lo=j+1) k bisect.bisect_left(L, l3_max, lo=j+1) bisect.bisect_left bisect bisect_left L l3_max lo=j+1 lo j+1 j 1 ans += max(0, k - j - 1) ans max(0, k - j - 1) max 0 k - j - 1 k - j k j 1 print(ans) print ans ans = 0 0 ans l3_max = (l1 + l2) l1 + l2 l3_max L = list(map(int, input().split())) list(map(int, input().split())) L l1 = L[i] L[i] l1 k = bisect.bisect_left(L, l3_max, lo=j+1) bisect.bisect_left(L, l3_max, lo=j+1) k ans += max(0, k - j - 1) max(0, k - j - 1) ans N = int(input()) int(input()) N l2 = L[j] L[j] l2
N = int(input())
L = list(map(int, input().split()))

L.sort()

# print(L)
import bisect
ans = 0
for i in range(N-2):
    l1 = L[i]
    for j in range(i+1, N-1):
        l2 = L[j]
        l3_max = (l1 + l2)

        k = bisect.bisect_left(L, l3_max, lo=j+1)
        ans += max(0, k - j - 1)
print(ans)