import bisect



def main():

    N = int(eval(input()))

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

    sort_L = sorted(L)

    cnt = 0

    for i in range(N-2):

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

            tmp = bisect.bisect_left(sort_L,sort_L[i] + sort_L[j])

            if tmp - 1 > j:

                cnt += tmp - j - 1

    print(cnt)



    



if __name__ == "__main__":

    main()
from bisect import bisect_right



def main():

    N = int(eval(input()))

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

    sort_L = sorted(L)

    ans = 0

    for i in range(N-2):

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

            if i == j:

                continue

            ok = j

            ng = N

            tmp = sort_L[i] + sort_L[j]

            while abs(ok - ng) > 1:

                mid = (ok + ng) // 2

                if sort_L[mid] < tmp:

                    ok = mid

                else:

                    ng = mid



            ans += ok - j



    print(ans)







if __name__ == "__main__":

    main()
import bisect


def main():
    N = int(eval(input()))
    L = list(map(int, input().split()))
    sort_L = sorted(L)
    cnt = 0
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            tmp = bisect.bisect_left(sort_L, sort_L[i] + sort_L[j])
            if tmp - 1 > j:
                cnt += tmp - j - 1
    print(cnt)


if __name__ == "__main__":
    main()

from bisect import bisect_right


def main():
    N = int(eval(input()))
    L = list(map(int, input().split()))
    sort_L = sorted(L)
    ans = 0
    for i in range(N - 2):
        for j in range(i, N - 1):
            if i == j:
                continue
            ok = j
            ng = N
            tmp = sort_L[i] + sort_L[j]
            while abs(ok - ng) > 1:
                mid = (ok + ng) // 2
                if sort_L[mid] < tmp:
                    ok = mid
                else:
                    ng = mid
            ans += ok - j
    print(ans)


if __name__ == "__main__":
    main()

-import bisect +from bisect import bisect_right -    cnt = 0 +    ans = 0 -        for j in range(i + 1, N - 1): -            tmp = bisect.bisect_left(sort_L, sort_L[i] + sort_L[j]) -            if tmp - 1 > j: -                cnt += tmp - j - 1 -    print(cnt) +        for j in range(i, N - 1): +            if i == j: +                continue +            ok = j +            ng = N +            tmp = sort_L[i] + sort_L[j] +            while abs(ok - ng) > 1: +                mid = (ok + ng) // 2 +                if sort_L[mid] < tmp: +                    ok = mid +                else: +                    ng = mid +            ans += ok - j +    print(ans)