import bisect





def main():

    N = int(eval(input()))

    edges = [int(i) for i in input().split()]

    edges.sort()

    ans = 0

    for a in range(N - 2):

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

            ans += bisect.bisect_left(edges, edges[a] + edges[b])-b-1



    print(ans)





if __name__ == "__main__":

    main()
import sys

# sys.setrecursionlimit(100000)

import bisect





def input():

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





def input_int():

    return int(eval(input()))





def input_int_list():

    return [int(i) for i in input().split()]





def main():

    n = input_int()

    L = sorted(input_int_list())

    ans = 0

    for i in range(n - 2):

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

            idx = bisect.bisect_left(L, L[i] + L[j])

            ans += idx - j - 1

    print(ans)

    return





if __name__ == "__main__":

    main()

import bisect


def main():
    N = int(eval(input()))
    edges = [int(i) for i in input().split()]
    edges.sort()
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            ans += bisect.bisect_left(edges, edges[a] + edges[b]) - b - 1
    print(ans)


if __name__ == "__main__":
    main()

import sys

# sys.setrecursionlimit(100000)
import bisect


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


def input_int():
    return int(eval(input()))


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    L = sorted(input_int_list())
    ans = 0
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            idx = bisect.bisect_left(L, L[i] + L[j])
            ans += idx - j - 1
    print(ans)
    return


if __name__ == "__main__":
    main()

+import sys + +# sys.setrecursionlimit(100000) +def input(): +    return sys.stdin.readline().strip() + + +def input_int(): +    return int(eval(input())) + + +def input_int_list(): +    return [int(i) for i in input().split()] + + -    N = int(eval(input())) -    edges = [int(i) for i in input().split()] -    edges.sort() +    n = input_int() +    L = sorted(input_int_list()) -    for a in range(N - 2): -        for b in range(a + 1, N - 1): -            ans += bisect.bisect_left(edges, edges[a] + edges[b]) - b - 1 +    for i in range(n - 2): +        for j in range(i + 1, n - 1): +            idx = bisect.bisect_left(L, L[i] + L[j]) +            ans += idx - j - 1 +    return