def biserch(n,List):
    left = 0
    right = len(List)
    while left < right:
        mid = (left+right)//2
        if n <= List[mid]:
            right = mid
        else:
            left = mid + 1
    
    return left
    
N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0
for i in range(N):
    for j in range(i+1,N):
        key = L[i] + L[j]
        anchor = biserch(key,L)
        
        ans += max(anchor - (j+1),0)

print(ans) def biserch(n,List):
    left = 0
    right = len(List)
    while left < right:
        mid = (left+right)//2
        if n <= List[mid]:
            right = mid
        else:
            left = mid + 1
    
    return left
     biserch left = 0 left 0 right = len(List) right len(List) len List while left < right:
        mid = (left+right)//2
        if n <= List[mid]:
            right = mid
        else:
            left = mid + 1
    
     left < right left right mid = (left+right)//2 mid (left+right)//2 left+right left right 2 if n <= List[mid]:
            right = mid
        else:
            left = mid + 1
    
     n <= List[mid] n List[mid] List mid right = mid right mid left = mid + 1 left mid + 1 mid 1 return left left n n List List 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 i in range(N):
    for j in range(i+1,N):
        key = L[i] + L[j]
        anchor = biserch(key,L)
        
        ans += max(anchor - (j+1),0) i range(N) range N for j in range(i+1,N):
        key = L[i] + L[j]
        anchor = biserch(key,L)
        
        ans += max(anchor - (j+1),0) j range(i+1,N) range i+1 i 1 N key = L[i] + L[j] key L[i] + L[j] L[i] L i L[j] L j anchor = biserch(key,L) anchor biserch(key,L) biserch key L ans += max(anchor - (j+1),0) ans max(anchor - (j+1),0) max anchor - (j+1) anchor j+1 j 1 0 print(ans) print ans def biserch(n,List):
    left = 0
    right = len(List)
    while left < right:
        mid = (left+right)//2
        if n <= List[mid]:
            right = mid
        else:
            left = mid + 1
    
    return left
     def biserch(n,List):
    left = 0
    right = len(List)
    while left < right:
        mid = (left+right)//2
        if n <= List[mid]:
            right = mid
        else:
            left = mid + 1
    
    return left
     biserch N = int(input()) int(input()) N ans = 0 0 ans key = L[i] + L[j] L[i] + L[j] key ans += max(anchor - (j+1),0) max(anchor - (j+1),0) ans L = list(map(int,input().split())) list(map(int,input().split())) L anchor = biserch(key,L) biserch(key,L) anchor
def biserch(n,List):
    left = 0
    right = len(List)
    while left < right:
        mid = (left+right)//2
        if n <= List[mid]:
            right = mid
        else:
            left = mid + 1
    
    return left
    
N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0
for i in range(N):
    for j in range(i+1,N):
        key = L[i] + L[j]
        anchor = biserch(key,L)
        
        ans += max(anchor - (j+1),0)

print(ans)