import bisect

import time



def main():

    N = int(eval(input()))

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

    #N = 2000

    #L = [int(i) for i in range(N)]



    L.sort()

    ans = 0

    for i in range(N-2):

        for j in range(i+1,N-1):

            #ans += bisect.bisect_left(L[j+1:], L[i]+L[j])

            index = bisect.bisect_left(L, L[i]+L[j])

            ans += (index - (j+1))



    print(ans)





if __name__ == "__main__":

    #start = time.time()

    main()

    #elapsed_time = time.time() - start

    #print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")

from bisect import bisect_left

import sys

read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines



def main():

    N = int(readline())

    L = [int(i) for i in readline().split()]

    L.sort()



    ans = 0

    for i in range(N-1):

        L_i = L[i]

        for j in range(i+1, N):

            idx = bisect_left(L, L_i + L[j])

            ans += idx - (j + 1)



    print(ans)





if __name__ == "__main__":

    main()

import bisect
import time


def main():
    N = int(eval(input()))
    L = [int(i) for i in input().split()]
    # N = 2000
    # L = [int(i) for i in range(N)]
    L.sort()
    ans = 0
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            # ans += bisect.bisect_left(L[j+1:], L[i]+L[j])
            index = bisect.bisect_left(L, L[i] + L[j])
            ans += index - (j + 1)
    print(ans)


if __name__ == "__main__":
    # start = time.time()
    main()
    # elapsed_time = time.time() - start
    # print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")

from bisect import bisect_left
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def main():
    N = int(readline())
    L = [int(i) for i in readline().split()]
    L.sort()
    ans = 0
    for i in range(N - 1):
        L_i = L[i]
        for j in range(i + 1, N):
            idx = bisect_left(L, L_i + L[j])
            ans += idx - (j + 1)
    print(ans)


if __name__ == "__main__":
    main()

-import bisect -import time +from bisect import bisect_left +import sys + +read = sys.stdin.read +readline = sys.stdin.readline +readlines = sys.stdin.readlines -    N = int(eval(input())) -    L = [int(i) for i in input().split()] -    # N = 2000 -    # L = [int(i) for i in range(N)] +    N = int(readline()) +    L = [int(i) for i in readline().split()] -    for i in range(N - 2): -        for j in range(i + 1, N - 1): -            # ans += bisect.bisect_left(L[j+1:], L[i]+L[j]) -            index = bisect.bisect_left(L, L[i] + L[j]) -            ans += index - (j + 1) +    for i in range(N - 1): +        L_i = L[i] +        for j in range(i + 1, N): +            idx = bisect_left(L, L_i + L[j]) +            ans += idx - (j + 1) -    # start = time.time() -    # elapsed_time = time.time() - start -    # print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")