import bisect
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    L=list(mi())

    ans = 0
    L.sort()
    for ai in range(N):
        for bi in range(ai+1,N):
            a,b = L[ai],L[bi]

            left = bisect.bisect_left(L,abs(a-b)+1)
            right = bisect.bisect_right(L,a+b-1)

            count = right - left

            if left <= ai <= right:
                count -= 1

            if left <= bi <= right:
                count -= 1
            
            ans += count
            # if count > 0:
            #     print(a,b,count) 
            

    print(ans//3)


if __name__ == "__main__":
    main() import bisect bisect import sys sys sys.setrecursionlimit(10**9) sys.setrecursionlimit sys setrecursionlimit 10**9 10 9 def mi(): return map(int,input().split()) mi def ii(): return int(input()) ii def isp(): return input().split() isp def deb(text): print("-------\n{}\n-------".format(text)) deb text text INF=10**20 INF 10**20 10 20 def main():
    N=ii()
    L=list(mi())

    ans = 0
    L.sort()
    for ai in range(N):
        for bi in range(ai+1,N):
            a,b = L[ai],L[bi]

            left = bisect.bisect_left(L,abs(a-b)+1)
            right = bisect.bisect_right(L,a+b-1)

            count = right - left

            if left <= ai <= right:
                count -= 1

            if left <= bi <= right:
                count -= 1
            
            ans += count
            # if count > 0:
            #     print(a,b,count) 
            

    print(ans//3) main N=ii() N ii() ii L=list(mi()) L list(mi()) list mi() mi ans = 0 ans 0 L.sort() L.sort L sort for ai in range(N):
        for bi in range(ai+1,N):
            a,b = L[ai],L[bi]

            left = bisect.bisect_left(L,abs(a-b)+1)
            right = bisect.bisect_right(L,a+b-1)

            count = right - left

            if left <= ai <= right:
                count -= 1

            if left <= bi <= right:
                count -= 1
            
            ans += count
            # if count > 0:
            #     print(a,b,count) 
            

     ai range(N) range N for bi in range(ai+1,N):
            a,b = L[ai],L[bi]

            left = bisect.bisect_left(L,abs(a-b)+1)
            right = bisect.bisect_right(L,a+b-1)

            count = right - left

            if left <= ai <= right:
                count -= 1

            if left <= bi <= right:
                count -= 1
            
            ans += count
            # if count > 0:
            #     print(a,b,count) 
            

     bi range(ai+1,N) range ai+1 ai 1 N a,b = L[ai],L[bi] a L[ai] L ai b L[bi] L bi left = bisect.bisect_left(L,abs(a-b)+1) left bisect.bisect_left(L,abs(a-b)+1) bisect.bisect_left bisect bisect_left L abs(a-b)+1 abs(a-b) abs a-b a b 1 right = bisect.bisect_right(L,a+b-1) right bisect.bisect_right(L,a+b-1) bisect.bisect_right bisect bisect_right L a+b-1 a+b a b 1 count = right - left count right - left right left if left <= ai <= right:
                count -= 1

             left <= ai <= right left <= ai left ai right count -= 1 count 1 if left <= bi <= right:
                count -= 1
            
             left <= bi <= right left <= bi left bi right count -= 1 count 1 ans += count ans count print(ans//3) print ans//3 ans 3 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main INF=10**20 10**20 INF def mi(): return map(int,input().split()) def mi(): return map(int,input().split()) mi def isp(): return input().split() def isp(): return input().split() isp def ii(): return int(input()) def ii(): return int(input()) ii def main():
    N=ii()
    L=list(mi())

    ans = 0
    L.sort()
    for ai in range(N):
        for bi in range(ai+1,N):
            a,b = L[ai],L[bi]

            left = bisect.bisect_left(L,abs(a-b)+1)
            right = bisect.bisect_right(L,a+b-1)

            count = right - left

            if left <= ai <= right:
                count -= 1

            if left <= bi <= right:
                count -= 1
            
            ans += count
            # if count > 0:
            #     print(a,b,count) 
            

    print(ans//3) def main():
    N=ii()
    L=list(mi())

    ans = 0
    L.sort()
    for ai in range(N):
        for bi in range(ai+1,N):
            a,b = L[ai],L[bi]

            left = bisect.bisect_left(L,abs(a-b)+1)
            right = bisect.bisect_right(L,a+b-1)

            count = right - left

            if left <= ai <= right:
                count -= 1

            if left <= bi <= right:
                count -= 1
            
            ans += count
            # if count > 0:
            #     print(a,b,count) 
            

    print(ans//3) main def deb(text): print("-------\n{}\n-------".format(text)) def deb(text): print("-------\n{}\n-------".format(text)) deb
import bisect
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    L=list(mi())

    ans = 0
    L.sort()
    for ai in range(N):
        for bi in range(ai+1,N):
            a,b = L[ai],L[bi]

            left = bisect.bisect_left(L,abs(a-b)+1)
            right = bisect.bisect_right(L,a+b-1)

            count = right - left

            if left <= ai <= right:
                count -= 1

            if left <= bi <= right:
                count -= 1
            
            ans += count
            # if count > 0:
            #     print(a,b,count) 
            

    print(ans//3)


if __name__ == "__main__":
    main()