import bisect
N = int(input())
L = list(map(int,input().split()))
ans = 0
L.sort()

for i in range(N-2):
    for j in range(i+1,N-1):
        num = L[i] + L[j]
        ind = bisect.bisect_right(L,num - 1)
        if ind > j - 1:
            ans += ind - j - 1
print(ans) import bisect 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 ans = 0 ans 0 L.sort() L.sort L sort for i in range(N-2):
    for j in range(i+1,N-1):
        num = L[i] + L[j]
        ind = bisect.bisect_right(L,num - 1)
        if ind > j - 1:
            ans += ind - j - 1 i range(N-2) range N-2 N 2 for j in range(i+1,N-1):
        num = L[i] + L[j]
        ind = bisect.bisect_right(L,num - 1)
        if ind > j - 1:
            ans += ind - j - 1 j range(i+1,N-1) range i+1 i 1 N-1 N 1 num = L[i] + L[j] num L[i] + L[j] L[i] L i L[j] L j ind = bisect.bisect_right(L,num - 1) ind bisect.bisect_right(L,num - 1) bisect.bisect_right bisect bisect_right L num - 1 num 1 if ind > j - 1:
            ans += ind - j - 1 ind > j - 1 ind j - 1 j 1 ans += ind - j - 1 ans ind - j - 1 ind - j ind j 1 print(ans) print ans ans = 0 0 ans L = list(map(int,input().split())) list(map(int,input().split())) L ans += ind - j - 1 ind - j - 1 ans num = L[i] + L[j] L[i] + L[j] num ind = bisect.bisect_right(L,num - 1) bisect.bisect_right(L,num - 1) ind N = int(input()) int(input()) N
import bisect
N = int(input())
L = list(map(int,input().split()))
ans = 0
L.sort()

for i in range(N-2):
    for j in range(i+1,N-1):
        num = L[i] + L[j]
        ind = bisect.bisect_right(L,num - 1)
        if ind > j - 1:
            ans += ind - j - 1
print(ans)