from itertools import combinations

from bisect import bisect_right



def main():

    N, *L = list(map(int, open(0).read().split()))



    L.sort()



    print((sum(bisect_right(L, L[i] + L[j] - 1, lo=j + 1) - (j + 1) for i, j in combinations(list(range(N)), 2))))



if __name__ == '__main__':

    main()

from itertools import combinations

from bisect import bisect_right



def main():

    N, *L = list(map(int, open(0).read().split()))



    L.sort()



    print((sum(bisect_right(L, L[i] + L[j] - 1, j + 1) - (j + 1) for i, j in combinations(list(range(N)), 2))))



if __name__ == '__main__':

    main()
from itertools import combinations
from bisect import bisect_right


def main():
    N, *L = list(map(int, open(0).read().split()))
    L.sort()
    print(
        (
            sum(
                bisect_right(L, L[i] + L[j] - 1, lo=j + 1) - (j + 1)
                for i, j in combinations(list(range(N)), 2)
            )
        )
    )


if __name__ == "__main__":
    main()

from itertools import combinations
from bisect import bisect_right


def main():
    N, *L = list(map(int, open(0).read().split()))
    L.sort()
    print(
        (
            sum(
                bisect_right(L, L[i] + L[j] - 1, j + 1) - (j + 1)
                for i, j in combinations(list(range(N)), 2)
            )
        )
    )


if __name__ == "__main__":
    main()

-                bisect_right(L, L[i] + L[j] - 1, lo=j + 1) - (j + 1) +                bisect_right(L, L[i] + L[j] - 1, j + 1) - (j + 1)