#!/usr/bin/env python3

import sys

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):

            diff = L[j] - L[i]

            index = bisect_right(L[:i],diff)

            ans += i-index

            # print(i,j,ans)

    print(ans)



if __name__ == '__main__':

    main()
#!/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()

#!/usr/bin/env python3
import sys
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):
            diff = L[j] - L[i]
            index = bisect_right(L[:i], diff)
            ans += i - index
            # print(i,j,ans)
    print(ans)


if __name__ == "__main__":
    main()

#!/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 +from bisect import bisect_left -            diff = L[j] - L[i] -            index = bisect_right(L[:i], diff) -            ans += i - index -            # print(i,j,ans) +            index = bisect_left(L, L[i] + L[j]) +            ans += max(0, index - j - 1)