N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
ans = 0

for i in range(N-2):
    for j in range(i+1, N-1):
        ok = i
        ng = N
        while ng - ok > 1:
            mid = (ok + ng) // 2
            if L[mid] > L[i] - L[j]:
                ok = mid
            else:
                ng = mid
        if ok > j:
            ans += ok - j
            
print(ans)
 N = int(input()) N int(input()) int input() input L = list(map(int, input().split())) L list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split L.sort(reverse=True) L.sort L sort reverse=True reverse True ans = 0 ans 0 for i in range(N-2):
    for j in range(i+1, N-1):
        ok = i
        ng = N
        while ng - ok > 1:
            mid = (ok + ng) // 2
            if L[mid] > L[i] - L[j]:
                ok = mid
            else:
                ng = mid
        if ok > j:
            ans += ok - j
             i range(N-2) range N-2 N 2 for j in range(i+1, N-1):
        ok = i
        ng = N
        while ng - ok > 1:
            mid = (ok + ng) // 2
            if L[mid] > L[i] - L[j]:
                ok = mid
            else:
                ng = mid
        if ok > j:
            ans += ok - j
             j range(i+1, N-1) range i+1 i 1 N-1 N 1 ok = i ok i ng = N ng N while ng - ok > 1:
            mid = (ok + ng) // 2
            if L[mid] > L[i] - L[j]:
                ok = mid
            else:
                ng = mid
         ng - ok > 1 ng - ok ng ok 1 mid = (ok + ng) // 2 mid (ok + ng) // 2 ok + ng ok ng 2 if L[mid] > L[i] - L[j]:
                ok = mid
            else:
                ng = mid
         L[mid] > L[i] - L[j] L[mid] L mid L[i] - L[j] L[i] L i L[j] L j ok = mid ok mid ng = mid ng mid if ok > j:
            ans += ok - j
             ok > j ok j ans += ok - j ans ok - j ok j print(ans) print ans ans = 0 0 ans ok = mid mid ok ng = N N ng ans += ok - j ok - j ans mid = (ok + ng) // 2 (ok + ng) // 2 mid ng = mid mid ng L = list(map(int, input().split())) list(map(int, input().split())) L ok = i i ok N = int(input()) int(input()) N
N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
ans = 0

for i in range(N-2):
    for j in range(i+1, N-1):
        ok = i
        ng = N
        while ng - ok > 1:
            mid = (ok + ng) // 2
            if L[mid] > L[i] - L[j]:
                ok = mid
            else:
                ng = mid
        if ok > j:
            ans += ok - j
            
print(ans)

