# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 21:39:55 2020

@author: liang
"""

# -*- 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()]

from bisect import bisect_left

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

@author: liang
""" """
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()] from bisect import bisect_left L.sort() L.sort L sort ans = 0 ans 0 for i in range(N-2):
    #print("1:",i)
    #p = i+2
    #以下O(2N)　定数倍が遅い
    for j in range(i+1,N-1):
        #print("2",i,j)
        t = L[i] + L[j]
        #while p < N and L[p] < L[i] + L[j] :
        #    p += 1
        p = bisect_left(L,t)
            #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 for j in range(i+1,N-1):
        #print("2",i,j)
        t = L[i] + L[j]
        #while p < N and L[p] < L[i] + L[j] :
        #    p += 1
        p = bisect_left(L,t)
            #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 t = L[i] + L[j] t L[i] + L[j] L[i] L i L[j] L j p = bisect_left(L,t) p bisect_left(L,t) bisect_left L t 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 N = int(input()) int(input()) N t = L[i] + L[j] L[i] + L[j] t p = bisect_left(L,t) bisect_left(L,t) p L = [int(x) for x in input().split()] [int(x) for x in input().split()] L ans = 0 0 ans ans += max(0, p - j -1) max(0, p - j -1) ans
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 21:39:55 2020

@author: liang
"""

# -*- 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()]

from bisect import bisect_left

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