
def binary_search(border, b):
    ok = b
    ng = n
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if L[mid] < border:
            ok = mid
        else:
            ng = mid

    return ok


n = int(input())
L = sorted(list(map(int, input().split())))
ans = 0

for a in range(0,n-1):
    for b in range(a+1, n):
        a_b = L[a] + L[b]
        ans += binary_search(a_b, b) - b

print(ans) def binary_search(border, b):
    ok = b
    ng = n
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if L[mid] < border:
            ok = mid
        else:
            ng = mid

    return ok binary_search ok = b ok b ng = n ng n while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if L[mid] < border:
            ok = mid
        else:
            ng = mid

     abs(ok - ng) > 1 abs(ok - ng) abs ok - ng ok ng 1 mid = (ok + ng) // 2 mid (ok + ng) // 2 ok + ng ok ng 2 if L[mid] < border:
            ok = mid
        else:
            ng = mid

     L[mid] < border L[mid] L mid border ok = mid ok mid ng = mid ng mid return ok ok border border b b n = int(input()) n int(input()) int input() input L = sorted(list(map(int, input().split()))) L sorted(list(map(int, input().split()))) sorted list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ans = 0 ans 0 for a in range(0,n-1):
    for b in range(a+1, n):
        a_b = L[a] + L[b]
        ans += binary_search(a_b, b) - b a range(0,n-1) range 0 n-1 n 1 for b in range(a+1, n):
        a_b = L[a] + L[b]
        ans += binary_search(a_b, b) - b b range(a+1, n) range a+1 a 1 n a_b = L[a] + L[b] a_b L[a] + L[b] L[a] L a L[b] L b ans += binary_search(a_b, b) - b ans binary_search(a_b, b) - b binary_search(a_b, b) binary_search a_b b b print(ans) print ans def binary_search(border, b):
    ok = b
    ng = n
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if L[mid] < border:
            ok = mid
        else:
            ng = mid

    return ok def binary_search(border, b):
    ok = b
    ng = n
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if L[mid] < border:
            ok = mid
        else:
            ng = mid

    return ok binary_search L = sorted(list(map(int, input().split()))) sorted(list(map(int, input().split()))) L a_b = L[a] + L[b] L[a] + L[b] a_b n = int(input()) int(input()) n ans = 0 0 ans ans += binary_search(a_b, b) - b binary_search(a_b, b) - b ans

def binary_search(border, b):
    ok = b
    ng = n
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if L[mid] < border:
            ok = mid
        else:
            ng = mid

    return ok


n = int(input())
L = sorted(list(map(int, input().split())))
ans = 0

for a in range(0,n-1):
    for b in range(a+1, n):
        a_b = L[a] + L[b]
        ans += binary_search(a_b, b) - b

print(ans)