
def is_triangle(a, b, c):
    if a >= b + c:
        return False

    if b >= a + c:
        return False

    if c >= a + b:
        return False

    return True


def main():
    N = int(input())
    L = list([int(x) for x in input().split()])

    L.sort()

    count = 0
    for index, a in enumerate(L):
        if index + 2 == N:
            break

        for b_i in range(index+1, N):
            b = L[b_i]
            c = 1

            while not is_triangle(a, b, L[-c]):
                c += 1

            count += (N - b_i - c)

    print(count)


if __name__ == '__main__':
    main() def is_triangle(a, b, c):
    if a >= b + c:
        return False

    if b >= a + c:
        return False

    if c >= a + b:
        return False

    return True is_triangle if a >= b + c:
        return False

     a >= b + c a b + c b c return False False if b >= a + c:
        return False

     b >= a + c b a + c a c return False False if c >= a + b:
        return False

     c >= a + b c a + b a b return False False return True True a a b b c c def main():
    N = int(input())
    L = list([int(x) for x in input().split()])

    L.sort()

    count = 0
    for index, a in enumerate(L):
        if index + 2 == N:
            break

        for b_i in range(index+1, N):
            b = L[b_i]
            c = 1

            while not is_triangle(a, b, L[-c]):
                c += 1

            count += (N - b_i - c)

    print(count) main N = int(input()) N int(input()) int input() input int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x L = list([int(x) for x in input().split()]) L list([int(x) for x in input().split()]) list [int(x) for x in input().split()] L.sort() L.sort L sort count = 0 count 0 for index, a in enumerate(L):
        if index + 2 == N:
            break

        for b_i in range(index+1, N):
            b = L[b_i]
            c = 1

            while not is_triangle(a, b, L[-c]):
                c += 1

            count += (N - b_i - c)

     index a enumerate(L) enumerate L if index + 2 == N:
            break

         index + 2 == N index + 2 index 2 N break for b_i in range(index+1, N):
            b = L[b_i]
            c = 1

            while not is_triangle(a, b, L[-c]):
                c += 1

            count += (N - b_i - c)

     b_i range(index+1, N) range index+1 index 1 N b = L[b_i] b L[b_i] L b_i c = 1 c 1 while not is_triangle(a, b, L[-c]):
                c += 1

             not is_triangle(a, b, L[-c]) is_triangle(a, b, L[-c]) is_triangle a b L[-c] L -c c c += 1 c 1 count += (N - b_i - c) count N - b_i - c N - b_i N b_i c print(count) print count if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    N = int(input())
    L = list([int(x) for x in input().split()])

    L.sort()

    count = 0
    for index, a in enumerate(L):
        if index + 2 == N:
            break

        for b_i in range(index+1, N):
            b = L[b_i]
            c = 1

            while not is_triangle(a, b, L[-c]):
                c += 1

            count += (N - b_i - c)

    print(count) def main():
    N = int(input())
    L = list([int(x) for x in input().split()])

    L.sort()

    count = 0
    for index, a in enumerate(L):
        if index + 2 == N:
            break

        for b_i in range(index+1, N):
            b = L[b_i]
            c = 1

            while not is_triangle(a, b, L[-c]):
                c += 1

            count += (N - b_i - c)

    print(count) main def is_triangle(a, b, c):
    if a >= b + c:
        return False

    if b >= a + c:
        return False

    if c >= a + b:
        return False

    return True def is_triangle(a, b, c):
    if a >= b + c:
        return False

    if b >= a + c:
        return False

    if c >= a + b:
        return False

    return True is_triangle

def is_triangle(a, b, c):
    if a >= b + c:
        return False

    if b >= a + c:
        return False

    if c >= a + b:
        return False

    return True


def main():
    N = int(input())
    L = list([int(x) for x in input().split()])

    L.sort()

    count = 0
    for index, a in enumerate(L):
        if index + 2 == N:
            break

        for b_i in range(index+1, N):
            b = L[b_i]
            c = 1

            while not is_triangle(a, b, L[-c]):
                c += 1

            count += (N - b_i - c)

    print(count)


if __name__ == '__main__':
    main()
