N = int(eval(input()))

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

L.sort()

count = 0

for i in range(N):

    a = L[i]

    k = i+2

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

        b = L[j]

        while k < N and a+b > L[k]:

            k += 1

        count += k - 1 - j

print(count)









#coding:utf-8

import sys

import bisect

sys.setrecursionlimit(10**6)

write = sys.stdout.write

dbg = lambda *something : print(*something) if DEBUG else 0

DEBUG = False

def main(given = sys.stdin.readline):

    input = lambda : given().rstrip()

    LMIIS = lambda : list(map(int,input().split()))

    II = lambda : int(input())

    XLMIIS = lambda x : [LMIIS() for _ in range(x)]





    n = II()

    l = LMIIS()

    a = [l[i] + l[j] for i in range(n) for j in range(i+1, n)]



    a.sort()

    ans = 0

    for ll in l:

        x =  bisect.bisect(a, ll)

        ans += x

    print(n*(n-1)*(n-2)//6 - ans)



if __name__ == '__main__':

    main()

N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
count = 0
for i in range(N):
    a = L[i]
    k = i + 2
    for j in range(i + 1, N):
        b = L[j]
        while k < N and a + b > L[k]:
            k += 1
        count += k - 1 - j
print(count)

# coding:utf-8
import sys
import bisect

sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something: print(*something) if DEBUG else 0
DEBUG = False


def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int, input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    n = II()
    l = LMIIS()
    a = [l[i] + l[j] for i in range(n) for j in range(i + 1, n)]
    a.sort()
    ans = 0
    for ll in l:
        x = bisect.bisect(a, ll)
        ans += x
    print(n * (n - 1) * (n - 2) // 6 - ans)


if __name__ == "__main__":
    main()

-N = int(eval(input())) -L = list(map(int, input().split())) -L.sort() -count = 0 -for i in range(N): -    a = L[i] -    k = i + 2 -    for j in range(i + 1, N): -        b = L[j] -        while k < N and a + b > L[k]: -            k += 1 -        count += k - 1 - j -print(count) +# coding:utf-8 +import sys +import bisect + +sys.setrecursionlimit(10**6) +write = sys.stdout.write +dbg = lambda *something: print(*something) if DEBUG else 0 +DEBUG = False + + +def main(given=sys.stdin.readline): +    input = lambda: given().rstrip() +    LMIIS = lambda: list(map(int, input().split())) +    II = lambda: int(input()) +    XLMIIS = lambda x: [LMIIS() for _ in range(x)] +    n = II() +    l = LMIIS() +    a = [l[i] + l[j] for i in range(n) for j in range(i + 1, n)] +    a.sort() +    ans = 0 +    for ll in l: +        x = bisect.bisect(a, ll) +        ans += x +    print(n * (n - 1) * (n - 2) // 6 - ans) + + +if __name__ == "__main__": +    main()