from bisect import bisect_left

n=int(eval(input()))

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

l.sort()

ans=0

for i in range(n-2):

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

        ans+=bisect_left(l,l[i]+l[j])-j-1

print(ans)
def main():

    from bisect import bisect_left

    n=int(eval(input()))

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

    l.sort()

    ans=0

    for i in range(n-2):

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

            ans+=bisect_left(l,l[i]+l[j])-j-1

    print(ans)

if __name__=="__main__":

    main()
from bisect import bisect_left

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

def main():
    from bisect import bisect_left

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


if __name__ == "__main__":
    main()

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