CodeEff/ECCO huggingface dataset:
# Original solution
from bisect import bisect_right,bisect_left
N = int(eval(input()))
L = sorted(list(map(int,input().split())))
cnt = 0
for i in range(N-1):
    for j in range(i+1,N):
        a = L[i]
        b = L[j]
        indU = bisect_left(L,a+b)
        indL = bisect_right(L,b-a)
        if j<indU and i>= indL:
            cnt += indU-indL-2
        elif indL<=i<indU and j>=indU or i<indL and indL<=j<indU:
            cnt += indU-indL-1
        elif j<indL or i>=indU:
            cnt += indU-indL
print((cnt//3))

# Optimized solution
from bisect import bisect_left
N = int(eval(input()))
L = sorted(list(map(int,input().split())))
cnt = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        a = L[i]
        b = L[j]
        ind = bisect_left(L,a+b)
        cnt += ind-j-1
print(cnt)
# Original solution
from bisect import bisect_left

N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
for i, a in enumerate(L[:N-2]):
  for j, b in enumerate(L[i+1:N-1]):
    over_index = bisect_left(L[i+j+2:],a+b)
    ans += over_index
print(ans)
      


# Optimized solution
from bisect import bisect_left

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

print(ans)
# Original solution
n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
s = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    ab = abs(l[i]-l[j])
    for k in range(j+1,n):
      if l[k] >= l[i] + l[j]:
        break
      if ab < l[k]:
        s += 1
print(s)

# Optimized solution
n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
s = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    high = n-1
    low = j+1
    ab = l[i] + l[j]
    if l[j+1] >= ab:
      continue
    while high - low > 1:
      mid = (high+low)//2
      if l[mid] < ab:
        low = mid
      else:
        high = mid
    if l[high] < ab:
      s += high - j
    else:
      s += low - j
print(s)
# Original solution
import collections

n = int(eval(input()))
L = sorted(map(int,input().split()))
ans = []
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      if L[i] < L[j] + L[k] and L[j] < L[k] + L[i] and L[k] < L[i] + L[j]:
        A = [i,j,k]
        A.sort()
        s = ''.join([str(n) for n in A])
        ans.append(s)
cnt = set(ans)  
print((len(cnt)))

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
A.sort()
count = 0

for i in range(N-1,0,-1):
    l = 0
    r = i -1
    while(l< r):
        if (A[l] + A[r] >A[i]):
            count += (r-l)
            r -= 1
        else:
            l += 1
print(count)
# Original solution
import bisect

def f(L):
    n = len(L)
    L.sort()
    count = 0
    # a=3 b=4 c=2, c < a + b => 2 < 3+4
    # a < b + c   =>  a - b < c  =>  c > a - b
    # b < c + a   =>  b - a < c  =>  c > b - a
    # c < a + b
    for i in range(n):
        for j in range(i + 1, n):
            a, b = L[i], L[j]
            start = bisect.bisect_left(L, max(a-b, b-a))
            end = bisect.bisect_left(L, a + b)
            for k in range(start, end):
                assert L[k] < a + b
                assert L[k] > a - b
#                assert L[k] > b - a
                if k != i and k != j and L[k] < a + b:
                    # other two checks
                    if L[k] < a + b and a < b + L[k] and b < L[k] + a:
                        count += 1
    return count // 3

assert f([3, 4, 2, 1]) == 1
assert f([1, 1000, 1]) == 0
assert f([218, 786, 704, 233, 645, 728, 389]) == 23

_N = eval(input())
L = list(map(int, input().split()))
ans = f(L)
print(ans)


# Optimized solution
import bisect

def f(L):
    n = len(L)
    L.sort()

    count = 0

    for i in range(n):
        for j in range(i + 1, n):
            a = L[i]
            b = L[j]
            start = max(a - b, b - a)
            end = a + b
            si = bisect.bisect_right(L, start)
            ei = bisect.bisect_left(L, end)
            zx = ei - si
            if i >= si and i < ei:
                zx -= 1
            if j >= si and j < ei:
                zx -= 1
            count += zx
    return count // 3

assert f([3, 4, 2, 1]) == 1
assert f([1, 1000, 1]) == 0
assert f([218, 786, 704, 233, 645, 728, 389]) == 23

_N = eval(input())
L = list(map(int, input().split()))
ans = f(L)
print(ans)
# Original solution
import sys
import itertools

input = sys.stdin.readline


def main():
    n = int(eval(input()))
    l = list(map(int, input().split()))
    # 種類組み合わせ・条件
    l = sorted(l)
    hoge = []
    for a, b in itertools.combinations(l, 2):
        target = l[:]
        target.remove(a)
        target.remove(b)
        hoge += [sorted([a, b, c]) for c in [x for x in target if b - a < x < a + b]]
    print((len(set(["{}{}{}".format(a, b, c) for a, b, c in hoge]))))
    # sum([str(i) for i in


if __name__ == "__main__":
    main()


# Optimized solution
import sys
import bisect

input = sys.stdin.readline


def main():
    n = int(eval(input()))
    l = list(map(int, input().split()))
    # 種類組み合わせ・条件
    l = sorted(l)
    hoge = 0
    for i, a in enumerate(l[:-2], start=1):
        for j, b in enumerate(l[i:-1], start=i):
            index = bisect.bisect_left(l, a + b)
            hoge += index - j - 1
    print(hoge)


if __name__ == "__main__":
    main()
# Original solution
n = int(eval(input()))
l = list(map(int,input().split()))
l.sort()
ans = 0
for i in range(n-2):
     for j in range(i + 1,n-1):
          flag = True
          for k in range(j + 1,n):
               if l[i] + l[j] > l[k]  :
                    ans += 1
               else:
                    break
print(ans)

# Optimized solution
import bisect
n = int(eval(input()))
l = list(map(int,input().split()))
l.sort()
ans = 0
for i in range(n-2):
     for j in range(i + 1,n-1):
          ans += bisect.bisect_left(l,l[i] + l[j]) - j - 1
print(ans)
# Original solution
def bin_search1(L1,L2,l,N):#長すぎる辺の個数を返す
    low = 0
    high = N-1
    while high-low>1:
        mid = (low+high)//2
        if (L1+L2<=l[mid]):#長すぎ
            high = mid
        else:
            low = mid
    if L1+L2>l[high]:#全部ok
        return 0
    elif L1+L2<=l[low]:#全部ng
        return N
    else:
        return N-high

def bin_search2(L1,L2,l,N):#短すぎる辺の個数を返す
    low = 0
    high = N-1
    while high-low>1:
        mid = (low+high)//2
        if (abs(L1-L2)>=l[mid]):
            low = mid
        else:
            high = mid
    if abs(L1-L2)<l[low]:
        return 0
    elif abs(L1-L2)>=l[high]:
        return N
    else:
        return high

N = int(eval(input()))
L = list(map(int,input().split()))
L.sort()

ans = 0

for i in range(N):
    for j in range(N):
        if i!=j:
            L_temp = L#修正面倒なため
            a = L[i]
            b = L[j]
            if i<j:
                L_temp.pop(j)
                L_temp.pop(i)
                ans += (N-2-bin_search1(a,b,L_temp,N-2)-bin_search2(a,b,L_temp,N-2))
                L.insert(i,a)
                L.insert(j,b)
            else:
                L_temp.pop(i)
                L_temp.pop(j)
                ans += (N-2-bin_search1(a,b,L_temp,N-2)-bin_search2(a,b,L_temp,N-2))
                L.insert(j,b)
                L.insert(i,a)
                
ans = ans//6

print(ans)

# Optimized solution
from bisect import bisect＿left

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

ans = 0

for i in range(N-1):
    for j in range(i+1,N):
        ans += bisect_left(L,L[i]+L[j])-(j+1)

print(ans)
# Original solution
import itertools
N=int(eval(input()))
L=list(map(int,input().split()))
C=list(itertools.combinations(L,3))
ans=0
for i in range(len(C)):
  if C[i][0]<C[i][1]+C[i][2] and C[i][1]<C[i][0]+C[i][2] and C[i][2]<C[i][1]+C[i][0]:
    ans+=1
print(ans)

# Optimized solution
import itertools
N=int(eval(input()))
L=list(map(int,input().split()))
C=[x for x in itertools.combinations(L,3) if x[0]<x[1]+x[2] and x[1]<x[0]+x[2] and x[2]<x[0]+x[1]]
print((len(C)))
# Original solution
import itertools
N=int(eval(input()))
L=list(map(int,input().split()))
ans=0
for x in itertools.combinations(L,3):
  if x[0]<x[1]+x[2] and x[1]<x[0]+x[2] and x[2]<x[0]+x[1]:
    ans+=1
print(ans)

# Optimized solution
import bisect
N=int(eval(input()))
L=sorted(list(map(int,input().split())))
ans=0
for i in range(N-2):
  for j in range(N-i-2):        
    ans+=min(N-i-j-2,N-bisect.bisect_left(L,L[-j-1]-L[i]+1)-j-1)
print(ans)
# Original solution
import itertools
import bisect
N = int(eval(input()))
L = list(map(int, input().split()))
ans = 0
LS = sorted(L)
l = len(LS)
for i in range(l):
  for j in range(l):
    if i < j:
      k = bisect.bisect_left(LS,LS[i]+LS[j])
      ans += k-j-1
print(ans)


# Optimized solution
import sys
import bisect
N = int(eval(input()))
L = list(map(int, input().split()))
LS = sorted(L)
ans = 0
for i in range(N):
  for j in range(N):
    if i < j:
      index = bisect.bisect_left(LS,LS[i]+LS[j])
      ans += index-j-1 

print(ans)
# Original solution
from itertools import combinations
N=int(eval(input()))
triangle=[]
count=0
L=list(map(int,input().split()))
for i in combinations(L,3):
    triangle.append(list(i))
for i in triangle:
    #print(i)
    if i[0]<i[1]+i[2] and i[1]<i[2]+i[0] and i[2]<i[1]+i[0]:
        count+=1
print(count)

# Optimized solution
from bisect import bisect_left
N=int(eval(input()))
triangle=[]
count=0
L=list(map(int,input().split()))
L.sort()
#print(L)
for a in range(N):
    for b in range(a+1,N):
        c=L[a]+L[b]
        zahyo=bisect_left(L,c)
        count+=max(0,zahyo-b-1)
print(count)
# Original solution
import bisect


def main():
    n = int(eval(input()))
    l_lst = list(map(int, input().split()))
    l_lst.sort()

    count = 0
    for i in range(n - 1):
        for j in range(i + 1, n):

            lst = l_lst[j + 1:]
            a = l_lst[i]
            b = l_lst[j]
            count += bisect.bisect_left(lst, a + b)

    print(count)


if __name__ == '__main__':
    main()

# Optimized solution
import bisect


def main():
    n = int(eval(input()))
    l_lst = list(map(int, input().split()))
    l_lst.sort()

    count = 0
    for i in range(n - 1):
        for j in range(i + 1, n):

            a = l_lst[i]
            b = l_lst[j]
            tmp = bisect.bisect_left(l_lst, a + b)
            tmp -= j + 1
            tmp = max(0, tmp)
            count += tmp

    print(count)


if __name__ == '__main__':
    main()
# Original solution
import bisect 
N = int(eval(input()))
L = sorted(list(map(int,input().split())))
ans = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    idx = bisect.bisect(L,L[i]+L[j]-1)
    ans += idx-j-1
print(ans)


# Optimized solution
import bisect

N = int(eval(input()))
L = sorted(list(map(int,input().split())))
ans = 0
for bi in range(1,N-1):
  for ai in range(0,bi):
    ci = bisect.bisect(L,L[bi]+L[ai]-1) - 1
    if bi<ci:
      ans += ci-bi
print(ans)
# Original solution
n=int(eval(input()))
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        k=j+1
        while k<n:
            if l[i]+l[j]>l[k]:
                k+=1
                ans+=1
            else:
                break
print(ans)


# Optimized solution
n=int(eval(input()))
p=list(map(int,input().split()))
p.sort()
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        if j<n-2:
            l=j+1
            r=n-1
            while r-l>1:
                c=(l+r)//2
                if p[c]>=p[i]+p[j]:
                    r=c
                else:
                    l=c
            if p[l]<p[i]+p[j]:
                ans+=l-j
            if p[r]<p[i]+p[j]:
                ans+=1
        if j==n-2:
            if p[i]+p[n-2]>p[n-1]:
                ans+=1
print(ans)
# Original solution
from bisect import bisect_left

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

L.sort()
result = 0
for i, a in enumerate(L, 1):
    for j, b in enumerate (L[i:], i+1):
        k = bisect_left(L[j:], a + b)
        result += k
print(result)


# Optimized solution
from bisect import bisect_left

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

L.sort()
result = 0
for i in range(N-2):
    a = L[i]
    for j in range(i+1, N-1):
        b = L[j]
        k = bisect_left(L, a + b, j + 1)
        result += k - (j + 1)
print(result)
# Original solution
import sys
input = sys.stdin.readline
from itertools import combinations
N=int(input().rstrip('\n'))
ls = [int(i) for i in input().rstrip('\n').split()]
ls = sorted(ls)
ok = [x for x in combinations(ls,3) if x[0]+x[1]>x[2]]
print((len(ok)))

# Optimized solution
import sys
input = sys.stdin.readline
N=int(input().rstrip('\n'))
ls = [int(i) for i in input().rstrip('\n').split()]
ls=sorted(ls,reverse = True)
res = 0
for x in range(N-2):
  a = ls[x]
  for y in range(x+1,N-1):
    b = ls[y]
    if a>(b+ls[y+1]):
      break
    else:
      for z in range(y+1,N):
        if a<(b+ls[z]):
          res += 1
        else:
          break
print(res)
# Original solution
from itertools import combinations
n = int(eval(input()))
l = list(int(i) for i in input().split())

cnt = 0

for bars in combinations(l, 3):
    a,b,c = bars[0], bars[1], bars[2]
    if a < b + c and b < a + c and c < b + a:
        cnt+=1

print(cnt)




# Optimized solution
import bisect


def main():
    n = int(eval(input()))
    l = sorted(list(int(i) for i in input().split()))

    cnt = 0

    for i in range(n - 2):
        a = l[i]
        for j in range(i + 1, n-1):
            b = l[j]
            cnt += bisect.bisect_left(l, a+b)-(j+1)

    print(cnt)


if __name__ == "__main__":
    main()
# Original solution
from bisect import bisect_left, bisect_right

n = int(eval(input()))
stick = list(map(int, input().split()))
stick.sort()

count = 0
for i in range(n):
    for j in range(i + 1, n):
        l = bisect_left(stick, stick[j] - stick[i] + 1)
        r = bisect_right(stick, stick[i] + stick[j] - 1) - 1
        if r < 0 or l >= n:
            break
        count += r - l + 1
        if l <= i <= r:
            count -= 1
        if l <= j <= r:
            count -= 1
print((count // 3))

# Optimized solution
from bisect import bisect_left, bisect_right

n = int(eval(input()))
stick = list(map(int, input().split()))
stick.sort()

count = 0
for i in range(n - 1, -1, -1):
    for j in range(i - 1, -1, -1):
        l = bisect_left(stick, stick[i] - stick[j] + 1)
        r = bisect_right(stick, stick[i] + stick[j] - 1) - 1
        if j <= l or l > r:
            break
        count += min(r + 1, j) - l
print(count)
# Original solution
from bisect import bisect_left

n = int(eval(input()))
l = sorted(list(map(int, input().split())))
answer = 0

for i in range(n - 2):
    for j in range(i + 1, n - 1):
        lij = l[i] + l[j]
        r = bisect_left(l, lij)
        answer += max(0, r - j - 1)
        
print(answer)


# Optimized solution
from bisect import bisect_left

n = int(eval(input()))
l = sorted(list(map(int, input().split())))
answer = 0

for i in range(n - 2):
    for j in range(i + 1, n - 1):
        lij = l[i] + l[j]
        r = bisect_left(l, lij)
        answer += r - j - 1
        
print(answer)
# Original solution
n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
triangle = 0
while len(l) >= 3:
  max_l = l.pop()
  for i in range(1, len(l)):
    rest_l = max_l - l[i]
    inf = -1
    sup = i
    while sup - inf > 1:
      x = (inf + sup) // 2
      if l[x] > rest_l:
        sup = x
      else:
        inf = x
    triangle += i - sup
print(triangle)

# Optimized solution
from bisect import bisect_left

n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
triangle = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    index = bisect_left(l, l[i] + l[j], j + 1, n) - 1
    triangle += index - j
print(triangle)
# Original solution
N=int(eval(input()))
S=list(map(int,input().split( )))
S = sorted(S)
tri_num=0
for i in range(N-2):
    k = i+2
    for j in range(i+1,N-1):
        while k < N:
            if S[i] + S[j] <= S[k]:
                tri_num = tri_num + k-j-1
                if k == i+2:
                    k+=1
                break
            if k == N-1:
                tri_num = tri_num + k-j
                break
            k+=1
print(tri_num)

# Optimized solution
N=int(eval(input()))
S=list(map(int,input().split( )))
S = sorted(S,reverse=True)
tri_num=0
for i in range(N-2):
    j = i+1
    k = N-1
    while k > j:
        if S[i] < S[j] + S[k]:
            tri_num += k-j
            j+=1
        else:
            k-=1
print(tri_num)
# Original solution
import bisect
import copy
def two_int():
    N, K = list(map(int, input().split()))
    return N,K

def one_int():
    return int(eval(input()))

def one_str():
    return eval(input())

def many_int():
    return list(map(int, input().split()))




N=one_int()
L=many_int()

L=sorted(L)

sankaku_dict={}
count=0
for i in range(len(L)-1):
    low=L[i]
    Lcopy = copy.deepcopy(L)
    Lcopy.remove(low)
    
    for j in range(i+1, len(L)):
        #すでに探索済みか判定
        high = L[j]
        Lcopy2 = Lcopy[j:]
        
        #下限を取得    
#         under_index = bisect.bisect_right(Lcopy2,high-low)
        #上限を取得
        high_index = bisect.bisect_left(Lcopy2,high+low)
        
#         for va in Lcopy2[under_index:high_index]:
#             temp = sorted([high,low, va])
#             temp = (temp[0]*10**8) + (temp[1]*10**4) + temp[2]
#             sankaku_dict[temp]=1
        count+=len(Lcopy2[:high_index])

# len(sankaku_dict)
print(count)
# print(len(sankaku_dict.keys()))

# Optimized solution
import bisect
import copy
def two_int():
    N, K = list(map(int, input().split()))
    return N,K

def one_int():
    return int(eval(input()))

def one_str():
    return eval(input())

def many_int():
    return list(map(int, input().split()))


N=one_int()
L=many_int()

L=sorted(L)

sankaku_dict={}
count=0
for i in range(len(L)-1):
    low=L[i]
    for j in range(i+1, len(L)):
        #すでに探索済みか判定
        high = L[j]
        
        #上限を取得
        high_index = bisect.bisect_left(L[j+1:], high+low)
        count+=high_index#len(L[j+1:high_index])

# len(sankaku_dict)
print(count)
# print(len(sankaku_dict.keys()))
# Original solution
N = int(eval(input()))
L = list(map(int, input().split()))
total = 0

L.sort(reverse=True)

for i in range(N-2):
    a = L[i]
    for j in range(i+1, N-1):
        b = L[j]
        for k in range(j+1, N):
            if a - b < L[k]:
                total += 1

print(total)


# Optimized solution
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort(reverse=True)
total = 0

for i in range(N-2):
    a = L[i]
    for j in range(i+1, N-1):
        b = L[j]
        # j以降の項で、初めてL[k] < a-bとなるkを二分探索する
        if L[-1] > a - b:  # 一番最後の項でもOKな場合(j+1以降全部OK)
            total += N - j - 1
        elif L[j+1] <= a - b:  # 一番最初の項からNGな場合
            continue
        else:
            head = j+1  # head はL[head] > a - bを満たす(OK側)
            tail = N-1  # tail はL[tail] <= a - bを満たす(NG側)
            while head+1 != tail:
                if L[(head + tail)//2] > a - b:  # 中間地点はOK側
                    head = (head + tail) // 2
                else:  # 中間地点はNG側
                    tail = (head + tail) // 2
            total += head - j

print(total)
# Original solution
import itertools

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

ans = 0
L.sort()

for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if L[k] < L[i]+L[j]:
                ans += 1
            else:
                break
print(ans)

# Optimized solution
import bisect

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

ans = 0
L.sort()

for i in range(n - 2):
    for j in range(i + 1, n - 1):
        idx = bisect.bisect_left(L, L[i] + L[j])
        ans += max(0, idx - j - 1)
print(ans)
# Original solution
import bisect

n=int(eval(input()))
l=sorted(map(int,input().split()))

t=0
for i in range(n):
  for j in range(i+1,n):
    a = j+1
    b = bisect.bisect_left(l,l[i]+l[j])
    t += b-a if b>a else 0

print(t)


# Optimized solution
import bisect

n=int(eval(input()))
l=sorted(map(int,input().split()))

t=0
for i in range(n):
  for j in range(i+1,n):
    t += bisect.bisect_left(l,l[i]+l[j]) - j - 1

print(t)
# Original solution
import itertools

def triangleChecker(combi):
    a, b, c = combi
    if a >= b + c :
        return False
    else:
        if b >= c + a:
            return False
        else :
            if c >= a + b:
                return False
            else :
                return True

N = int(eval(input()))
numbers = [int(i) for i in input().split()]

combinations = list(itertools.combinations(numbers, 3))

counter = 0
for combi in combinations:
    if triangleChecker(combi):
        # print(combi)
        counter += 1
print(counter)

# Optimized solution
def triangleChecker(a, b, c):
    if a >= b + c :
        return False
    else:
        if b >= c + a:
            return False
        else :
            if c >= a + b:
                return False
            else :
                return True
            
N = int(eval(input()))
numbers = [int(i) for i in input().split()]

counter = 0

for a in range(len(numbers)-2):
    for b in range(a+1, len(numbers)-1):
        for c in range(b+1, len(numbers)):
            if triangleChecker(numbers[a], numbers[b], numbers[c]):
                # print(combi)
                counter += 1

print(counter)
# Original solution

n=int(eval(input()))
l=list(map(int,input().split()))


def quicksort(a, left: int, right: int):
    #a[left]〜a[right]をクイックソート
    pl=left
    pr=right
    pivot= a[(left +right)//2]

    #print(f'a[{left}]~a[{right}] : ', *a[left : right +1])

    while pl<=pr:
        while a[pl] <pivot: pl+=1
        while a[pr] >pivot: pr-=1
        if pl <= pr:
            a[pl], a[pr]= a[pr], a[pl]
            pl+=1
            pr-=1

    if left < pr: quicksort(a, left, pr)
    if pl < right: quicksort(a, pl, right)

def quick_sort(a):
    quicksort(a, 0, len(a)-1)

quick_sort(l)
count=0
for i in range(n-2):
    for j in range(i+1,n-1):
        x=l[i]+l[j]
        for k in range(j+1,n):
            if x<=l[k]:
                break
            count+=1

print(count)

# Optimized solution

n=int(eval(input()))
l=list(map(int,input().split()))
from bisect import bisect_left
l.sort()

count=0
for a in range(n-2):
    for b in range(a+1,n-1):
        idx=bisect_left(l,l[a]+l[b],lo=b)
        count+=idx-(b+1)

print(count)
# Original solution
import itertools
N = int(eval(input()))
L = list(map(int,input().split()))
tri = list(itertools.combinations(L,3))
cnt = 0
for a,b,c in tri:
    if a < (b+c):
        if b < c+a:
            if c < a+b:
                cnt += 1
print(cnt)
    

# Optimized solution
import itertools
N = int(eval(input()))
L = list(map(int,input().split()))
L.sort()
tri = list(itertools.combinations(L,3))
cnt = 0
for a,b,c in tri:
    if a < (b+c) and b < (c+a) and c < (a+b):
        cnt += 1
print(cnt)
# Original solution
import bisect

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

L.sort()

buff = []
ll = []


for i in range(N):
    l_b = []
    for j in range(i+1, N):
        l_b.append(L[i]+L[j])
        ll.append(L[i]+L[j])
    if i != N-1:
        buff.append(l_b)
# buff.sort()
# print(L)
# print(buff)

ans = 0
_len = len(buff)

for i in range(_len):
    for j in range(len(buff[i])):
        index = bisect.bisect_left(L[i+j+1+1:], buff[i][j])
        # print(L[i+j+1+1:])
        # print(index, buff[i][j])
        ans += index
print(ans)


# for i in range(N):
#     index = bisect.bisect_left(buff, L[i])
#     print(index)
#     ans += index
# print(ans)


# Optimized solution
import bisect

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

L.sort()

buff = []
# ll = []


for i in range(N):
    l_b = []
    for j in range(i+1, N):
        l_b.append(L[i]+L[j])
        # ll.append(L[i]+L[j])
    if i != N-1:
        buff.append(l_b)
# buff.sort()
# print(L)
# print(buff)

ans = 0
_len = len(buff)

for i in range(_len):
    for j in range(len(buff[i])):
        index = bisect.bisect_left(L[i+j+1+1:], buff[i][j])
        # print(L[i+j+1+1:])
        # print(index, buff[i][j])
        ans += index
print(ans)


# for i in range(N):
#     index = bisect.bisect_left(buff, L[i])
#     print(index)
#     ans += index
# print(ans)