N = int(eval(input()))

L = list(map(int,input().split()))

L.sort()



ans=0

for i in range(N-2):

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

        ng=N

        ok=j

        while abs(ok-ng)!=1:

            med =(ok+ng)//2

            if L[med]<L[i]+L[j]:

                ok=med

            else:

                ng=med

        ans+=ok-j

print(ans)
import sys

input = sys.stdin.readline



def I(): return int(eval(input()))

def MI(): return list(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()

N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N - 2):
    for j in range(i + 1, N):
        ng = N
        ok = j
        while abs(ok - ng) != 1:
            med = (ok + ng) // 2
            if L[med] < L[i] + L[j]:
                ok = med
            else:
                ng = med
        ans += ok - j
print(ans)

import sys

input = sys.stdin.readline


def I():
    return int(eval(input()))


def MI():
    return list(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()

-N = int(eval(input())) -L = list(map(int, input().split())) -L.sort() -ans = 0 -for i in range(N - 2): -    for j in range(i + 1, N): -        ng = N -        ok = j -        while abs(ok - ng) != 1: -            med = (ok + ng) // 2 -            if L[med] < L[i] + L[j]: -                ok = med -            else: -                ng = med -        ans += ok - j -print(ans) +import sys + +input = sys.stdin.readline + + +def I(): +    return int(eval(input())) + + +def MI(): +    return list(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()