from bisect import bisect_left
N = int(input())
L_list = list(map(int, input().split()))
L_list.sort()

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        a, b = L_list[i], L_list[j]
        r = bisect_left(L_list, a+b)
        ans += max(0,r-j-1)
print(ans) from bisect import bisect_left N = int(input()) N int(input()) int input() input L_list = list(map(int, input().split())) L_list list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split L_list.sort() L_list.sort L_list sort ans = 0 ans 0 for i in range(N):
    for j in range(i + 1, N):
        a, b = L_list[i], L_list[j]
        r = bisect_left(L_list, a+b)
        ans += max(0,r-j-1) i range(N) range N for j in range(i + 1, N):
        a, b = L_list[i], L_list[j]
        r = bisect_left(L_list, a+b)
        ans += max(0,r-j-1) j range(i + 1, N) range i + 1 i 1 N a, b = L_list[i], L_list[j] a L_list[i] L_list i b L_list[j] L_list j r = bisect_left(L_list, a+b) r bisect_left(L_list, a+b) bisect_left L_list a+b a b ans += max(0,r-j-1) ans max(0,r-j-1) max 0 r-j-1 r-j r j 1 print(ans) print ans L_list = list(map(int, input().split())) list(map(int, input().split())) L_list b = L_list[i], L_list[j] L_list[j] b ans = 0 0 ans r = bisect_left(L_list, a+b) bisect_left(L_list, a+b) r a, b = L_list[i], L_list[j] L_list[i] a N = int(input()) int(input()) N ans += max(0,r-j-1) max(0,r-j-1) ans
from bisect import bisect_left
N = int(input())
L_list = list(map(int, input().split()))
L_list.sort()

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        a, b = L_list[i], L_list[j]
        r = bisect_left(L_list, a+b)
        ans += max(0,r-j-1)
print(ans)
