import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    import bisect
    
    mod=10**9+7
    N=I()
    L=LI()
    L.sort()
    ans=0
    for i in range(N):
        for j in range(i+1,N):
            a=L[i]
            b=L[j]
            ab=a+b
            num=bisect.bisect_left(L,ab)
            
            # print(i,j,num-j)
            ans+=num-j-1
            
                
    print(ans)
    

main() import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def I(): return int(input()) I def MI(): return map(int, input().split()) MI def LI(): return list(map(int, input().split())) LI def main():
    import bisect
    
    mod=10**9+7
    N=I()
    L=LI()
    L.sort()
    ans=0
    for i in range(N):
        for j in range(i+1,N):
            a=L[i]
            b=L[j]
            ab=a+b
            num=bisect.bisect_left(L,ab)
            
            # print(i,j,num-j)
            ans+=num-j-1
            
                
    print(ans)
     main import bisect bisect mod=10**9+7 mod 10**9+7 10**9 10 9 7 N=I() N I() I L=LI() L LI() LI L.sort() L.sort L sort ans=0 ans 0 for i in range(N):
        for j in range(i+1,N):
            a=L[i]
            b=L[j]
            ab=a+b
            num=bisect.bisect_left(L,ab)
            
            # print(i,j,num-j)
            ans+=num-j-1
            
                
     i range(N) range N for j in range(i+1,N):
            a=L[i]
            b=L[j]
            ab=a+b
            num=bisect.bisect_left(L,ab)
            
            # print(i,j,num-j)
            ans+=num-j-1
            
                
     j range(i+1,N) range i+1 i 1 N a=L[i] a L[i] L i b=L[j] b L[j] L j ab=a+b ab a+b a b num=bisect.bisect_left(L,ab) num bisect.bisect_left(L,ab) bisect.bisect_left bisect bisect_left L ab ans+=num-j-1 ans num-j-1 num-j num j 1 print(ans) print ans main() main def I(): return int(input()) def I(): return int(input()) I input = sys.stdin.readline sys.stdin.readline input def MI(): return map(int, input().split()) def MI(): return map(int, input().split()) MI def LI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) LI def main():
    import bisect
    
    mod=10**9+7
    N=I()
    L=LI()
    L.sort()
    ans=0
    for i in range(N):
        for j in range(i+1,N):
            a=L[i]
            b=L[j]
            ab=a+b
            num=bisect.bisect_left(L,ab)
            
            # print(i,j,num-j)
            ans+=num-j-1
            
                
    print(ans)
     def main():
    import bisect
    
    mod=10**9+7
    N=I()
    L=LI()
    L.sort()
    ans=0
    for i in range(N):
        for j in range(i+1,N):
            a=L[i]
            b=L[j]
            ab=a+b
            num=bisect.bisect_left(L,ab)
            
            # print(i,j,num-j)
            ans+=num-j-1
            
                
    print(ans)
     main
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    import bisect
    
    mod=10**9+7
    N=I()
    L=LI()
    L.sort()
    ans=0
    for i in range(N):
        for j in range(i+1,N):
            a=L[i]
            b=L[j]
            ab=a+b
            num=bisect.bisect_left(L,ab)
            
            # print(i,j,num-j)
            ans+=num-j-1
            
                
    print(ans)
    

main()
