import bisect

import sys



sys.setrecursionlimit(10 ** 6)

INF = float("inf")

MOD = 10 ** 9 + 7





def input():

    return sys.stdin.readline().strip()





def 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 - 1):

            ab = L[i] + L[j]

            idx = bisect.bisect_left(L, ab)

            ans += max(idx - j - 1, 0)



    print(ans)





if __name__ == "__main__":

    main()

import sys

from bisect import bisect_left



sys.setrecursionlimit(10 ** 6)

INF = float("inf")

MOD = 10 ** 9 + 7





def input():

    return sys.stdin.readline().strip()





def main():

    N = int(eval(input()))

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

    L.sort()

    ans = 0

    for i in range(N):

        a = L[i]

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

            b = L[j]

            ans += max(bisect_left(L, a + b) - (j + 1), 0)



    print(ans)





if __name__ == "__main__":

    main()

import bisect
import sys

sys.setrecursionlimit(10**6)
INF = float("inf")
MOD = 10**9 + 7


def input():
    return sys.stdin.readline().strip()


def 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 - 1):
            ab = L[i] + L[j]
            idx = bisect.bisect_left(L, ab)
            ans += max(idx - j - 1, 0)
    print(ans)


if __name__ == "__main__":
    main()

import sys
from bisect import bisect_left

sys.setrecursionlimit(10**6)
INF = float("inf")
MOD = 10**9 + 7


def input():
    return sys.stdin.readline().strip()


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


if __name__ == "__main__":
    main()

-import bisect +from bisect import bisect_left -    for i in range(N - 2): -        for j in range(i + 1, N - 1): -            ab = L[i] + L[j] -            idx = bisect.bisect_left(L, ab) -            ans += max(idx - j - 1, 0) +    for i in range(N): +        a = L[i] +        for j in range(i + 1, N): +            b = L[j] +            ans += max(bisect_left(L, a + b) - (j + 1), 0)