# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 20:56:06 2020

@author: liang
"""

N = int(input())
L = [int(x) for x in input().split()]

L.sort()
ans = 0
#print(L)
for i in range(N-2):
    #print("1:",i)
    p = i+2
    #以下O(2?N)　定数倍が遅い
    for j in range(i+1,N-1):
        #print("2",i,j)
        while p < N and L[p] < L[i] + L[j] :
            p += 1
            #print("up")
        #print(p)
        #ans += len(L[j+1:p])
        ans += max(0, p - j - 1)
print(ans) """
Created on Wed Sep  9 20:56:06 2020

@author: liang
""" N = int(input()) N int(input()) int input() input int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x L = [int(x) for x in input().split()] L [int(x) for x in input().split()] L.sort() L.sort L sort ans = 0 ans 0 for i in range(N-2):
    #print("1:",i)
    p = i+2
    #以下O(2?N)　定数倍が遅い
    for j in range(i+1,N-1):
        #print("2",i,j)
        while p < N and L[p] < L[i] + L[j] :
            p += 1
            #print("up")
        #print(p)
        #ans += len(L[j+1:p])
        ans += max(0, p - j - 1) i range(N-2) range N-2 N 2 p = i+2 p i+2 i 2 for j in range(i+1,N-1):
        #print("2",i,j)
        while p < N and L[p] < L[i] + L[j] :
            p += 1
            #print("up")
        #print(p)
        #ans += len(L[j+1:p])
        ans += max(0, p - j - 1) j range(i+1,N-1) range i+1 i 1 N-1 N 1 while p < N and L[p] < L[i] + L[j] :
            p += 1
            #print("up")
        #print(p)
        #ans += len(L[j+1:p])
         p < N and L[p] < L[i] + L[j] p < N p N L[p] < L[i] + L[j] L[p] L p L[i] + L[j] L[i] L i L[j] L j p += 1 p 1 ans += max(0, p - j - 1) ans max(0, p - j - 1) max 0 p - j - 1 p - j p j 1 print(ans) print ans ans += max(0, p - j - 1) max(0, p - j - 1) ans p += 1 1 p ans = 0 0 ans p = i+2 i+2 p L = [int(x) for x in input().split()] [int(x) for x in input().split()] L N = int(input()) int(input()) N
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 20:56:06 2020

@author: liang
"""

N = int(input())
L = [int(x) for x in input().split()]

L.sort()
ans = 0
#print(L)
for i in range(N-2):
    #print("1:",i)
    p = i+2
    #以下O(2?N)　定数倍が遅い
    for j in range(i+1,N-1):
        #print("2",i,j)
        while p < N and L[p] < L[i] + L[j] :
            p += 1
            #print("up")
        #print(p)
        #ans += len(L[j+1:p])
        ans += max(0, p - j - 1)
print(ans)