#!/usr/bin/env python3

import sys

from bisect import bisect_left



def main():

    N = int(eval(input()))

    L = sorted(list(map(int, input().split())))

    ans = 0



    for i in range(N-1):

        for j in range(i+1,N):

            index = bisect_left(L,L[i]+L[j])

            ans += max(0,index-j-1)

    print(ans)



if __name__ == '__main__':

    main()

from bisect import bisect_right



N = int(eval(input()))

L = list(map(int, input().split()))

L.sort()

ans = 0

for i in range(N):

    for j in range(i + 1, N):

        b = L[i]

        c = L[j]

        M = L[i+1:j]

        ans += bisect_right(M, b + c - 1) - bisect_right(M, c - b)

print(ans)
#!/usr/bin/env python3
import sys
from bisect import bisect_left


def main():
    N = int(eval(input()))
    L = sorted(list(map(int, input().split())))
    ans = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            index = bisect_left(L, L[i] + L[j])
            ans += max(0, index - j - 1)
    print(ans)


if __name__ == "__main__":
    main()

from bisect import bisect_right

N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        b = L[i]
        c = L[j]
        M = L[i + 1 : j]
        ans += bisect_right(M, b + c - 1) - bisect_right(M, c - b)
print(ans)

-#!/usr/bin/env python3 -import sys -from bisect import bisect_left +from bisect import bisect_right - -def main(): -    N = int(eval(input())) -    L = sorted(list(map(int, input().split()))) -    ans = 0 -    for i in range(N - 1): -        for j in range(i + 1, N): -            index = bisect_left(L, L[i] + L[j]) -            ans += max(0, index - j - 1) -    print(ans) - - -if __name__ == "__main__": -    main() +N = int(eval(input())) +L = list(map(int, input().split())) +L.sort() +ans = 0 +for i in range(N): +    for j in range(i + 1, N): +        b = L[i] +        c = L[j] +        M = L[i + 1 : j] +        ans += bisect_right(M, b + c - 1) - bisect_right(M, c - b) +print(ans)