from bisect import bisect_left



def main():

    N = int(eval(input()))

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



    ans = 0

    for ia in range(N):

        for ib in range(ia+1, N-1):

            a = L[ia]

            b = L[ib]

            ic_end = bisect_left(L, a+b, lo=ib+1)

            ans += ic_end - (ib+1)



    print(ans)

main()
def main():

    N = int(eval(input()))

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

    ans = 0

    for ia in range(N-2):

        a = L[ia]

        ic = ia + 2

        for ib in range(ia+1, N-1):

            b = L[ib]

            while ic < N and L[ic] < a+b:

                ic += 1

            ans += ic - (ib + 1)

    print(ans)

main()
from bisect import bisect_left


def main():
    N = int(eval(input()))
    L = sorted(list(map(int, input().split())))
    ans = 0
    for ia in range(N):
        for ib in range(ia + 1, N - 1):
            a = L[ia]
            b = L[ib]
            ic_end = bisect_left(L, a + b, lo=ib + 1)
            ans += ic_end - (ib + 1)
    print(ans)


main()

def main():
    N = int(eval(input()))
    L = sorted(list(map(int, input().split())))
    ans = 0
    for ia in range(N - 2):
        a = L[ia]
        ic = ia + 2
        for ib in range(ia + 1, N - 1):
            b = L[ib]
            while ic < N and L[ic] < a + b:
                ic += 1
            ans += ic - (ib + 1)
    print(ans)


main()

-from bisect import bisect_left - - -    for ia in range(N): +    for ia in range(N - 2): +        a = L[ia] +        ic = ia + 2 -            a = L[ia] -            ic_end = bisect_left(L, a + b, lo=ib + 1) -            ans += ic_end - (ib + 1) +            while ic < N and L[ic] < a + b: +                ic += 1 +            ans += ic - (ib + 1)