def main():
    from collections import deque
    from bisect import bisect_left

    n = int(input())
    l = sorted(map(int, input().split()))
    ld = deque(l)
    cnt = 0
    for a in range(n - 2):
        l_a = ld.popleft()
        for b in range(a + 1, n - 1):
            cnt += bisect_left(l, l_a + l[b]) - b - 1
    print(cnt)


if __name__ == "__main__":
    main() def main():
    from collections import deque
    from bisect import bisect_left

    n = int(input())
    l = sorted(map(int, input().split()))
    ld = deque(l)
    cnt = 0
    for a in range(n - 2):
        l_a = ld.popleft()
        for b in range(a + 1, n - 1):
            cnt += bisect_left(l, l_a + l[b]) - b - 1
    print(cnt) main from collections import deque from bisect import bisect_left n = int(input()) n int(input()) int input() input l = sorted(map(int, input().split())) l sorted(map(int, input().split())) sorted map(int, input().split()) map int input().split() ().split () input split ld = deque(l) ld deque(l) deque l cnt = 0 cnt 0 for a in range(n - 2):
        l_a = ld.popleft()
        for b in range(a + 1, n - 1):
            cnt += bisect_left(l, l_a + l[b]) - b - 1
     a range(n - 2) range n - 2 n 2 l_a = ld.popleft() l_a ld.popleft() ld.popleft ld popleft for b in range(a + 1, n - 1):
            cnt += bisect_left(l, l_a + l[b]) - b - 1
     b range(a + 1, n - 1) range a + 1 a 1 n - 1 n 1 cnt += bisect_left(l, l_a + l[b]) - b - 1 cnt bisect_left(l, l_a + l[b]) - b - 1 bisect_left(l, l_a + l[b]) - b bisect_left(l, l_a + l[b]) bisect_left l l_a + l[b] l_a l[b] l b b 1 print(cnt) print cnt if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    from collections import deque
    from bisect import bisect_left

    n = int(input())
    l = sorted(map(int, input().split()))
    ld = deque(l)
    cnt = 0
    for a in range(n - 2):
        l_a = ld.popleft()
        for b in range(a + 1, n - 1):
            cnt += bisect_left(l, l_a + l[b]) - b - 1
    print(cnt) def main():
    from collections import deque
    from bisect import bisect_left

    n = int(input())
    l = sorted(map(int, input().split()))
    ld = deque(l)
    cnt = 0
    for a in range(n - 2):
        l_a = ld.popleft()
        for b in range(a + 1, n - 1):
            cnt += bisect_left(l, l_a + l[b]) - b - 1
    print(cnt) main
def main():
    from collections import deque
    from bisect import bisect_left

    n = int(input())
    l = sorted(map(int, input().split()))
    ld = deque(l)
    cnt = 0
    for a in range(n - 2):
        l_a = ld.popleft()
        for b in range(a + 1, n - 1):
            cnt += bisect_left(l, l_a + l[b]) - b - 1
    print(cnt)


if __name__ == "__main__":
    main()