import sys

from bisect import bisect_left



input = sys.stdin.readline





def main():

    N = int(eval(input()))

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



    L.sort()

    ans = 0

    for i in range(N - 1):

        a = L[i]

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

            k = bisect_left(L, a + L[j], lo=j)

            ans += (k - 1 - j)



    print(ans)





if __name__ == "__main__":

    main()

import sys

from bisect import bisect_left



input = sys.stdin.readline





def main():

    N = int(eval(input()))

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



    L.sort()

    ans = 0

    for i in range(N - 1):

        a = L[i]

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

            k = bisect_left(L, a + L[j])

            ans += (k - 1 - j)



    print(ans)





if __name__ == "__main__":

    main()

import sys
from bisect import bisect_left

input = sys.stdin.readline


def main():
    N = int(eval(input()))
    L = list(map(int, input().split()))
    L.sort()
    ans = 0
    for i in range(N - 1):
        a = L[i]
        for j in range(i + 1, N):
            k = bisect_left(L, a + L[j], lo=j)
            ans += k - 1 - j
    print(ans)


if __name__ == "__main__":
    main()

import sys
from bisect import bisect_left

input = sys.stdin.readline


def main():
    N = int(eval(input()))
    L = list(map(int, input().split()))
    L.sort()
    ans = 0
    for i in range(N - 1):
        a = L[i]
        for j in range(i + 1, N):
            k = bisect_left(L, a + L[j])
            ans += k - 1 - j
    print(ans)


if __name__ == "__main__":
    main()

-            k = bisect_left(L, a + L[j], lo=j) +            k = bisect_left(L, a + L[j])