import itertools, bisect

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

ans = 0
for i in range(N):
    for j in range(i+1, N):
        cindex = bisect.bisect_left(L, int(L[i]) + int(L[j]))
        ans += cindex-1 - j

print(ans) import itertools, bisect itertools bisect 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 ans = 0 ans 0 for i in range(N):
    for j in range(i+1, N):
        cindex = bisect.bisect_left(L, int(L[i]) + int(L[j]))
        ans += cindex-1 - j i range(N) range N for j in range(i+1, N):
        cindex = bisect.bisect_left(L, int(L[i]) + int(L[j]))
        ans += cindex-1 - j j range(i+1, N) range i+1 i 1 N cindex = bisect.bisect_left(L, int(L[i]) + int(L[j])) cindex bisect.bisect_left(L, int(L[i]) + int(L[j])) bisect.bisect_left bisect bisect_left L int(L[i]) + int(L[j]) int(L[i]) int L[i] L i int(L[j]) int L[j] L j ans += cindex-1 - j ans cindex-1 - j cindex-1 cindex 1 j print(ans) print ans ans = 0 0 ans cindex = bisect.bisect_left(L, int(L[i]) + int(L[j])) bisect.bisect_left(L, int(L[i]) + int(L[j])) cindex ans += cindex-1 - j cindex-1 - j ans L = list(map(int, input().split())) list(map(int, input().split())) L N = int(input()) int(input()) N
import itertools, bisect

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

ans = 0
for i in range(N):
    for j in range(i+1, N):
        cindex = bisect.bisect_left(L, int(L[i]) + int(L[j]))
        ans += cindex-1 - j

print(ans)
