import bisect

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

ans = 0
for a in range(0,n):
    for b in range(a+1,n):
        p = bisect.bisect_left(L, L[a]+L[b])
        ans += max(p-(b+1),0)
        
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 L.sort() L.sort L sort ans = 0 ans 0 for a in range(0,n):
    for b in range(a+1,n):
        p = bisect.bisect_left(L, L[a]+L[b])
        ans += max(p-(b+1),0)
         a range(0,n) range 0 n for b in range(a+1,n):
        p = bisect.bisect_left(L, L[a]+L[b])
        ans += max(p-(b+1),0)
         b range(a+1,n) range a+1 a 1 n p = bisect.bisect_left(L, L[a]+L[b]) p bisect.bisect_left(L, L[a]+L[b]) bisect.bisect_left bisect bisect_left L L[a]+L[b] L[a] L a L[b] L b ans += max(p-(b+1),0) ans max(p-(b+1),0) max p-(b+1) p b+1 b 1 0 print(ans) print ans n = int(input()) int(input()) n ans = 0 0 ans p = bisect.bisect_left(L, L[a]+L[b]) bisect.bisect_left(L, L[a]+L[b]) p ans += max(p-(b+1),0) max(p-(b+1),0) ans L = list(map(int,input().split())) list(map(int,input().split())) L
import bisect

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

ans = 0
for a in range(0,n):
    for b in range(a+1,n):
        p = bisect.bisect_left(L, L[a]+L[b])
        ans += max(p-(b+1),0)
        
print(ans)