n = int(input())
ls = list(map(int,input().split()))
ls.sort()
p = 0
def is_ok(arg,l):
    return ls[arg] < l
def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        l = ls[i] + ls[j]
        if is_ok(mid,l):
            ok = mid
        else:
            ng = mid
    return ok
for i in range(n-2):
    for j in range(i+1,n-1):
        ng = n
        ok = j
        m = meguru_bisect(ng, ok)
        p += m-j 
print(p) n = int(input()) n int(input()) int input() input ls = list(map(int,input().split())) ls list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ls.sort() ls.sort ls sort p = 0 p 0 def is_ok(arg,l):
    return ls[arg] < l is_ok return ls[arg] < l ls[arg] < l ls[arg] ls arg l arg arg l l def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        l = ls[i] + ls[j]
        if is_ok(mid,l):
            ok = mid
        else:
            ng = mid
    return ok meguru_bisect while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        l = ls[i] + ls[j]
        if is_ok(mid,l):
            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 l = ls[i] + ls[j] l ls[i] + ls[j] ls[i] ls i ls[j] ls j if is_ok(mid,l):
            ok = mid
        else:
            ng = mid
     is_ok(mid,l) is_ok mid l ok = mid ok mid ng = mid ng mid return ok ok ng ng ok ok for i in range(n-2):
    for j in range(i+1,n-1):
        ng = n
        ok = j
        m = meguru_bisect(ng, ok)
        p += m-j  i range(n-2) range n-2 n 2 for j in range(i+1,n-1):
        ng = n
        ok = j
        m = meguru_bisect(ng, ok)
        p += m-j  j range(i+1,n-1) range i+1 i 1 n-1 n 1 ng = n ng n ok = j ok j m = meguru_bisect(ng, ok) m meguru_bisect(ng, ok) meguru_bisect ng ok p += m-j p m-j m j print(p) print p p += m-j m-j p n = int(input()) int(input()) n def is_ok(arg,l):
    return ls[arg] < l def is_ok(arg,l):
    return ls[arg] < l is_ok def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        l = ls[i] + ls[j]
        if is_ok(mid,l):
            ok = mid
        else:
            ng = mid
    return ok def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        l = ls[i] + ls[j]
        if is_ok(mid,l):
            ok = mid
        else:
            ng = mid
    return ok meguru_bisect ok = j j ok ls = list(map(int,input().split())) list(map(int,input().split())) ls p = 0 0 p m = meguru_bisect(ng, ok) meguru_bisect(ng, ok) m ng = n n ng
n = int(input())
ls = list(map(int,input().split()))
ls.sort()
p = 0
def is_ok(arg,l):
    return ls[arg] < l
def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        l = ls[i] + ls[j]
        if is_ok(mid,l):
            ok = mid
        else:
            ng = mid
    return ok
for i in range(n-2):
    for j in range(i+1,n-1):
        ng = n
        ok = j
        m = meguru_bisect(ng, ok)
        p += m-j 
print(p)
