
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(reverse=True)

    count = 0
    for a_i in range(N-2):
        b_i = a_i + 1
        c_i = 1
        while b_i + c_i < N:

            if not is_triangle(L[a_i], L[b_i], L[-c_i]):
                c_i += 1

            else:
                count += (N - b_i - c_i)
                b_i += 1

    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(reverse=True)

    count = 0
    for a_i in range(N-2):
        b_i = a_i + 1
        c_i = 1
        while b_i + c_i < N:

            if not is_triangle(L[a_i], L[b_i], L[-c_i]):
                c_i += 1

            else:
                count += (N - b_i - c_i)
                b_i += 1

    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(reverse=True) L.sort L sort reverse=True reverse True count = 0 count 0 for a_i in range(N-2):
        b_i = a_i + 1
        c_i = 1
        while b_i + c_i < N:

            if not is_triangle(L[a_i], L[b_i], L[-c_i]):
                c_i += 1

            else:
                count += (N - b_i - c_i)
                b_i += 1

     a_i range(N-2) range N-2 N 2 b_i = a_i + 1 b_i a_i + 1 a_i 1 c_i = 1 c_i 1 while b_i + c_i < N:

            if not is_triangle(L[a_i], L[b_i], L[-c_i]):
                c_i += 1

            else:
                count += (N - b_i - c_i)
                b_i += 1

     b_i + c_i < N b_i + c_i b_i c_i N if not is_triangle(L[a_i], L[b_i], L[-c_i]):
                c_i += 1

            else:
                count += (N - b_i - c_i)
                b_i += 1

     not is_triangle(L[a_i], L[b_i], L[-c_i]) is_triangle(L[a_i], L[b_i], L[-c_i]) is_triangle L[a_i] L a_i L[b_i] L b_i L[-c_i] L -c_i c_i c_i += 1 c_i 1 count += (N - b_i - c_i) count N - b_i - c_i N - b_i N b_i c_i b_i += 1 b_i 1 print(count) print count if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' 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 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 main():
    N = int(input())
    L = list([int(x) for x in input().split()])

    L.sort(reverse=True)

    count = 0
    for a_i in range(N-2):
        b_i = a_i + 1
        c_i = 1
        while b_i + c_i < N:

            if not is_triangle(L[a_i], L[b_i], L[-c_i]):
                c_i += 1

            else:
                count += (N - b_i - c_i)
                b_i += 1

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

    L.sort(reverse=True)

    count = 0
    for a_i in range(N-2):
        b_i = a_i + 1
        c_i = 1
        while b_i + c_i < N:

            if not is_triangle(L[a_i], L[b_i], L[-c_i]):
                c_i += 1

            else:
                count += (N - b_i - c_i)
                b_i += 1

    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 main():
    N = int(input())
    L = list([int(x) for x in input().split()])

    L.sort(reverse=True)

    count = 0
    for a_i in range(N-2):
        b_i = a_i + 1
        c_i = 1
        while b_i + c_i < N:

            if not is_triangle(L[a_i], L[b_i], L[-c_i]):
                c_i += 1

            else:
                count += (N - b_i - c_i)
                b_i += 1

    print(count)


if __name__ == '__main__':
    main()
