from collections import deque

from bisect import bisect_left



n = int(eval(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(eval(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()
from collections import deque
from bisect import bisect_left

n = int(eval(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(eval(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()

-from collections import deque -from bisect import bisect_left +def main(): +    from collections import deque +    from bisect import bisect_left -n = int(eval(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) +    n = int(eval(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()