import bisect



def main():

    n = int(eval(input()))

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

    ll.sort()



    ans = 0

    for i in range(n-2):

        e1 = ll[i]

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

            e2 = ll[j]

            # ans += bisect.bisect_left(ll[j+1:], e1+e2)

            comb = bisect.bisect_left(ll, e1+e2)

            comb -= (j+1)

            ans += max(comb,0)



    print(ans)





if __name__ == "__main__":

    main()
import bisect



n = int(eval(input()))

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

ll.sort()



ans = 0

for i in range(n-2):

    e1 = ll[i]

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

        e2 = ll[j]

        comb = bisect.bisect_left(ll, e1+e2)

        comb -= (j+1)

        ans += max(comb,0)



print(ans)



import bisect


def main():
    n = int(eval(input()))
    ll = list(map(int, input().split()))
    ll.sort()
    ans = 0
    for i in range(n - 2):
        e1 = ll[i]
        for j in range(i + 1, n - 1):
            e2 = ll[j]
            # ans += bisect.bisect_left(ll[j+1:], e1+e2)
            comb = bisect.bisect_left(ll, e1 + e2)
            comb -= j + 1
            ans += max(comb, 0)
    print(ans)


if __name__ == "__main__":
    main()

import bisect

n = int(eval(input()))
ll = list(map(int, input().split()))
ll.sort()
ans = 0
for i in range(n - 2):
    e1 = ll[i]
    for j in range(i + 1, n - 1):
        e2 = ll[j]
        comb = bisect.bisect_left(ll, e1 + e2)
        comb -= j + 1
        ans += max(comb, 0)
print(ans)

- -def main(): -    n = int(eval(input())) -    ll = list(map(int, input().split())) -    ll.sort() -    ans = 0 -    for i in range(n - 2): -        e1 = ll[i] -        for j in range(i + 1, n - 1): -            e2 = ll[j] -            # ans += bisect.bisect_left(ll[j+1:], e1+e2) -            comb = bisect.bisect_left(ll, e1 + e2) -            comb -= j + 1 -            ans += max(comb, 0) -    print(ans) - - -if __name__ == "__main__": -    main() +n = int(eval(input())) +ll = list(map(int, input().split())) +ll.sort() +ans = 0 +for i in range(n - 2): +    e1 = ll[i] +    for j in range(i + 1, n - 1): +        e2 = ll[j] +        comb = bisect.bisect_left(ll, e1 + e2) +        comb -= j + 1 +        ans += max(comb, 0) +print(ans)