N=int(eval(input()))

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

L.sort()



ans=0

from bisect import bisect_right

for i in range(N-1,-1,-1):

    li = L[i]

    for j in range(i-1,-1,-1):

        lj = L[j]

        k = bisect_right(L, li-lj)

        ans += max(0, j-k)

print(ans)
from bisect import bisect_right

import sys

def main():

    input = sys.stdin.readline

    N = int(eval(input()))

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

    L.sort()

    ans = 0

    for i in range(2, N):

        for j in range(i):

            k = bisect_right(L, L[i] - L[j], j + 1, i)

            ans += i - k

    print(ans)



if __name__ == '__main__':

    main()

N = int(eval(input()))
(*L,) = list(map(int, input().split()))
L.sort()
ans = 0
from bisect import bisect_right

for i in range(N - 1, -1, -1):
    li = L[i]
    for j in range(i - 1, -1, -1):
        lj = L[j]
        k = bisect_right(L, li - lj)
        ans += max(0, j - k)
print(ans)

from bisect import bisect_right
import sys


def main():
    input = sys.stdin.readline
    N = int(eval(input()))
    (*L,) = list(map(int, input().split()))
    L.sort()
    ans = 0
    for i in range(2, N):
        for j in range(i):
            k = bisect_right(L, L[i] - L[j], j + 1, i)
            ans += i - k
    print(ans)


if __name__ == "__main__":
    main()

-N = int(eval(input())) -(*L,) = list(map(int, input().split())) -L.sort() -ans = 0 +import sys -for i in range(N - 1, -1, -1): -    li = L[i] -    for j in range(i - 1, -1, -1): -        lj = L[j] -        k = bisect_right(L, li - lj) -        ans += max(0, j - k) -print(ans) + +def main(): +    input = sys.stdin.readline +    N = int(eval(input())) +    (*L,) = list(map(int, input().split())) +    L.sort() +    ans = 0 +    for i in range(2, N): +        for j in range(i): +            k = bisect_right(L, L[i] - L[j], j + 1, i) +            ans += i - k +    print(ans) + + +if __name__ == "__main__": +    main()