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 a in range(N - 2):

        for b in range(a + 1, N - 1):

            x = bisect_left(L, L[a] + L[b], lo=b)

            ans += (x - 1 - b)



    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 a in range(N - 2):

        for b in range(a + 1, N - 1):

            x = bisect_left(L, L[a] + L[b])

            ans += (x - 1 - b)



    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 a in range(N - 2):
        for b in range(a + 1, N - 1):
            x = bisect_left(L, L[a] + L[b], lo=b)
            ans += x - 1 - b
    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 a in range(N - 2):
        for b in range(a + 1, N - 1):
            x = bisect_left(L, L[a] + L[b])
            ans += x - 1 - b
    print(ans)


if __name__ == "__main__":
    main()

-            x = bisect_left(L, L[a] + L[b], lo=b) +            x = bisect_left(L, L[a] + L[b])