import sys

sys.setrecursionlimit(2147483647)

INF=float("inf")

MOD=10**9+7

input=lambda :sys.stdin.readline().rstrip()

def resolve():

    from bisect import bisect_left

    n=int(eval(input()))

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

    L.sort()

    ans=0

    for i in range(1,n):

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

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

            ans+=max(0,i-k)

    print(ans)

resolve()
import sys

sys.setrecursionlimit(2147483647)

INF=float("inf")

MOD=10**9+7

input=lambda :sys.stdin.readline().rstrip()

def resolve():

    n=int(eval(input()))

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

    L.sort()

    ans=0

    for b in range(1,n-1):

        c=b+1

        for a in range(b):

            while(c<n and L[a]+L[b]>L[c]): c+=1

            ans+=c-b-1

    print(ans)

resolve()
import sys

sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7
input = lambda: sys.stdin.readline().rstrip()


def resolve():
    from bisect import bisect_left

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


resolve()

import sys

sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7
input = lambda: sys.stdin.readline().rstrip()


def resolve():
    n = int(eval(input()))
    L = list(map(int, input().split()))
    L.sort()
    ans = 0
    for b in range(1, n - 1):
        c = b + 1
        for a in range(b):
            while c < n and L[a] + L[b] > L[c]:
                c += 1
            ans += c - b - 1
    print(ans)


resolve()

-    from bisect import bisect_left - -    for i in range(1, n): -        for j in range(i + 1, n): -            k = bisect_left(L, L[j] - L[i] + 1) -            ans += max(0, i - k) +    for b in range(1, n - 1): +        c = b + 1 +        for a in range(b): +            while c < n and L[a] + L[b] > L[c]: +                c += 1 +            ans += c - b - 1