N = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0
max = l[N-1]
tc = N
st = [j+1 for j in range(N-1)]
for i in range(N-2):
    if l[i]+l[i+1] > max:
        k = N-i-1
        ans += ((k-1)*k*(k+1))//6
        break
    for j in range(i+1,N-1):
        if j == tc:
            ans += tp
            break
        s = l[i]+l[j]
        if s <= l[j+1]:
            continue
        if s > max:
            tc = j 
            tp = (N-j-1) * (N-j) //2 #これをiの中でできないか
            ans += tp
            break
        start = st[j]
        if s <= l[start]:
            ans += start-j-1
            continue
        end = N
        while start != end:
            center = (start + end)//2
            if s <= l[center]:
                end = center
            else:
                start = center + 1
        st[j] = end
        ans += end-j-1
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() l.sort l sort ans = 0 ans 0 max = l[N-1] max l[N-1] l N-1 N 1 tc = N tc N j+1 for j in range(N-1) for j in range(N-1) j range(N-1) range N-1 N 1 for j in range(N-1) j+1 j 1 st = [j+1 for j in range(N-1)] st [j+1 for j in range(N-1)] for i in range(N-2):
    if l[i]+l[i+1] > max:
        k = N-i-1
        ans += ((k-1)*k*(k+1))//6
        break
    for j in range(i+1,N-1):
        if j == tc:
            ans += tp
            break
        s = l[i]+l[j]
        if s <= l[j+1]:
            continue
        if s > max:
            tc = j 
            tp = (N-j-1) * (N-j) //2 #これをiの中でできないか
            ans += tp
            break
        start = st[j]
        if s <= l[start]:
            ans += start-j-1
            continue
        end = N
        while start != end:
            center = (start + end)//2
            if s <= l[center]:
                end = center
            else:
                start = center + 1
        st[j] = end
        ans += end-j-1 i range(N-2) range N-2 N 2 if l[i]+l[i+1] > max:
        k = N-i-1
        ans += ((k-1)*k*(k+1))//6
        break
     l[i]+l[i+1] > max l[i]+l[i+1] l[i] l i l[i+1] l i+1 i 1 max k = N-i-1 k N-i-1 N-i N i 1 ans += ((k-1)*k*(k+1))//6 ans ((k-1)*k*(k+1))//6 (k-1)*k*(k+1) (k-1)*k k-1 k 1 k k+1 k 1 6 break for j in range(i+1,N-1):
        if j == tc:
            ans += tp
            break
        s = l[i]+l[j]
        if s <= l[j+1]:
            continue
        if s > max:
            tc = j 
            tp = (N-j-1) * (N-j) //2 #これをiの中でできないか
            ans += tp
            break
        start = st[j]
        if s <= l[start]:
            ans += start-j-1
            continue
        end = N
        while start != end:
            center = (start + end)//2
            if s <= l[center]:
                end = center
            else:
                start = center + 1
        st[j] = end
        ans += end-j-1 j range(i+1,N-1) range i+1 i 1 N-1 N 1 if j == tc:
            ans += tp
            break
         j == tc j tc ans += tp ans tp break s = l[i]+l[j] s l[i]+l[j] l[i] l i l[j] l j if s <= l[j+1]:
            continue
         s <= l[j+1] s l[j+1] l j+1 j 1 continue if s > max:
            tc = j 
            tp = (N-j-1) * (N-j) //2 #これをiの中でできないか
            ans += tp
            break
         s > max s max tc = j tc j tp = (N-j-1) * (N-j) //2 tp (N-j-1) * (N-j) //2 (N-j-1) * (N-j) N-j-1 N-j N j 1 N-j N j 2 ans += tp ans tp break start = st[j] start st[j] st j if s <= l[start]:
            ans += start-j-1
            continue
         s <= l[start] s l[start] l start ans += start-j-1 ans start-j-1 start-j start j 1 continue end = N end N while start != end:
            center = (start + end)//2
            if s <= l[center]:
                end = center
            else:
                start = center + 1
         start != end start end center = (start + end)//2 center (start + end)//2 start + end start end 2 if s <= l[center]:
                end = center
            else:
                start = center + 1
         s <= l[center] s l[center] l center end = center end center start = center + 1 start center + 1 center 1 st[j] = end st[j] st j end ans += end-j-1 ans end-j-1 end-j end j 1 print(ans) print ans center = (start + end)//2 (start + end)//2 center tp = (N-j-1) * (N-j) //2 (N-j-1) * (N-j) //2 tp tc = N N tc ans += ((k-1)*k*(k+1))//6 ((k-1)*k*(k+1))//6 ans ans += tp tp ans st = [j+1 for j in range(N-1)] [j+1 for j in range(N-1)] st start = st[j] st[j] start end = center center end start = center + 1 center + 1 start ans += end-j-1 end-j-1 ans s = l[i]+l[j] l[i]+l[j] s ans = 0 0 ans max = l[N-1] l[N-1] max ans += start-j-1 start-j-1 ans k = N-i-1 N-i-1 k end = N N end N = int(input()) int(input()) N tc = j j tc l = list(map(int,input().split())) list(map(int,input().split())) l ans += tp tp ans
N = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0
max = l[N-1]
tc = N
st = [j+1 for j in range(N-1)]
for i in range(N-2):
    if l[i]+l[i+1] > max:
        k = N-i-1
        ans += ((k-1)*k*(k+1))//6
        break
    for j in range(i+1,N-1):
        if j == tc:
            ans += tp
            break
        s = l[i]+l[j]
        if s <= l[j+1]:
            continue
        if s > max:
            tc = j 
            tp = (N-j-1) * (N-j) //2 #これをiの中でできないか
            ans += tp
            break
        start = st[j]
        if s <= l[start]:
            ans += start-j-1
            continue
        end = N
        while start != end:
            center = (start + end)//2
            if s <= l[center]:
                end = center
            else:
                start = center + 1
        st[j] = end
        ans += end-j-1
print(ans)