CodeEff/ECCO huggingface dataset:
# Original solution
N = int(eval(input()))

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

def check_triangle(a, b, c):
    if a < b + c and b < c + a and c < a + b:
        return True
    return False

sum = 0 
L.sort()
for i, l_1 in enumerate(L[:-2]):
    for j, l_2 in enumerate(L[i+1:-1]):
        for l_3 in L[i + j + 2:]:
            if check_triangle(l_1, l_2, l_3):
                sum += 1
            else:
                break

print(sum)


# Optimized solution
N = int(eval(input()))

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

count = 0 
L.sort()

for i in range(N-2):
    k = i + 2
    for j in range(i+1,N):
        while (k<N and L[i] + L[j] > L[k]):
            k += 1

        if k > j:
            count += k - j - 1


print(count)
# Original solution
import itertools

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

cnt = 0
for a, b, c in list(itertools.combinations(L,3)):
    if a<b+c and b<a+c and c<a+b:
        cnt += 1

print(cnt)

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

L.sort()

cnt = 0
for i in range(N-2):
    a = L[i]
    for j in range(i+1, N-1):
        b = L[j]
        for s in range(N-1, j, -1):
            c = L[s]
            if L[s]<L[i]+L[j]:
                cnt += s - j
                break
print(cnt)
# Original solution
import itertools
N = int(eval(input()))
L =list(map(int,input().split()))
S = []
ans = 0
for i, j, k in itertools.combinations(L,3):
  S.append([i, j, k])
for a, b, c in S:
  if a < b + c and b < c + a and c < a + b:
    ans += 1
print(ans)

# Optimized solution
import bisect
N = int(eval(input()))
L = list(map(int,input().split()))
L = sorted(L)
ans = 0
for i in range(N):
  for j in range(i+1,N):
    x = bisect.bisect_left(L,L[i] + L[j])
    ans += x - j - 1
print(ans)
# Original solution
n=int(eval(input()))
L=list(map(int,input().split()))
L=sorted(L)

from itertools import combinations
from bisect import bisect_right,bisect_left

comb=combinations(L, 2)
cnt=0
for cb in comb:
    b,c=min(cb), max(cb)
    # a must be b or lower
    hi=bisect_left(L, b)
    low=bisect_right(L, c-b)
    #print(b,c,hi,low)
    cnt+=max(0,hi-low)
print(cnt)

# Optimized solution
from bisect import bisect_left

n=int(eval(input()))
L=list(map(int,input().split()))
L=sorted(L)
ans=0
for i in range(n-2):
    a=L[i]
    for j in range(i+1,n-1):
        ans+=bisect_left(L,a+L[j])-j-1
print(ans)
# Original solution
n = int(eval(input()))
l = list(map(int, input().split()))

l = sorted(l, reverse = True)

ans = []
for i in range(len(l)-2):
    for j in range(len(l)-2-i):
        if l[i] > 2 * l[i+j+1]:
            break
        for k in range(len(l)-2-i-j):
            if l[i] < l[i+j+1] + l[i+j+k+2]:
                if [l[i], l[i+j+1], l[i+j+k+2]] not in ans:
                    ans.append([l[i], l[i+j+1], l[i+j+k+2]])
            else:
                break

print((len(ans)))
    

         
        
        
    

        
            
        
    
        




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

l.sort(reverse=True)
ans = 0
for i in range(n-2):
    j = i+1
    k = n-1
    while (j < k):
        if l[i] - l[j] - l[k] < 0:
            ans += k - j
            j += 1
        else:
            k -= 1

print(ans)
# Original solution
import bisect

N = int(eval(input()))
arr = list(map(int,input().split()))
arr = sorted(arr)
cnt = 0
for i in range(N-1):
  for j in range(N-i-1):
    a = arr[i]
    b = arr[i+j+1]
    if (i+j+2) < N:
      k = i+j+2
      upper = bisect.bisect_left(arr[k:], (a+b))
      cnt += upper

print(cnt)

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
a = sorted(a)
def trian(a):
    n=len(a)
    res = 0
    # 最小辺x
    for x in range(n):
        z=x+2
        # 真ん中の辺y
        for y in range(x+1,n):
            # 最大の辺z
            # nより小さく、二辺の和よりも小さい
            while(z<n and a[x]+a[y]>a[z]):
                z+=1
            # y+1から毎回数えるのではなく、yが増えれば、zも増えるのを利用し、前回の値を保存しておく
            res += z-y-1
    return res
print((trian(a)))
# Original solution
N = int(eval(input()))
L = sorted(map(int, input().split()), reverse=True)
cnt = 0

for i in range(N - 2):
    c = L[i]
    
    for j in range(i + 1, N - 1):
        b = L[j]
        l = j
        r = N - 1
        
        while True:
            idx = -(-(l + r) // 2)
            
            if L[idx] > abs(b - c):
                if l == idx:
                    break
                l = idx
            else:
                if r == idx:
                    break
                r = idx
                
        cnt += l - j
        
print(cnt)

# Optimized solution
N = int(eval(input()))
L = sorted(map(int, input().split()), reverse=True)
cnt = 0

for i in range(N - 2):
    c = L[i]
    
    for j in range(i + 1, N - 1):
        b = L[j]
        l = j
        r = N - 1
        
        while True:
            idx = -(-(l + r) // 2)
            
            if L[idx] > c - b:
                if l == idx:
                    break
                l = idx
            else:
                if r == idx:
                    break
                r = idx
                
        cnt += l - j
        
print(cnt)
# Original solution
N = int(eval(input()))
L = list(map(int,input().split()))

ans = 0

for i in range(N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      li = L[i]
      lj = L[j]
      lk = L[k]
      if ((li+lj)>lk)&((lj+lk)>li)&((li+lk)>lj):
        ans += 1
      else:
        continue
        
print(ans)

# Optimized solution
N = int(eval(input()))
L = list(map(int,input().split()))
import bisect
 
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
from bisect import bisect_left, bisect_right
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
for i, a in enumerate(L):
    for j, b in enumerate(L[i+1:]):
        l = abs(a - b)
        r = a + b
        top = bisect_left(L[i+j+2:], r)
        bot = bisect_right(L[i+j+2:], l)
        ans += top - bot
print(ans)


# Optimized solution
from bisect import bisect_left, bisect_right
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-1, 1, -1):
    for j in range(i - 1, 0, -1):
        x = L[i] - L[j]
        bottom = bisect_right(L, x)
        if j > bottom:
            ans += j - bottom
print(ans)
# Original solution
n = int(eval(input()))
l = list(map(int, input().split()))
ans = 0
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[i] + l[k] and l[k] < l[j] + l[i]:
                ans += 1
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
import itertools as it 
 
n = eval(input())
l = list(map(int, input().split()))
 
l.sort()
 
triangles = set()
for a, b, c in it.combinations(l, 3):
    if a + b > c and b + c > a and a + c > b:
        triangles.add((a, b, c))
 
print((len(triangles)))

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

l.sort()
count = 0
  
for i in range(0,n-2): 

    k = i + 2

    for j in range(i+1,n): 

        while (k < n and l[i] + l[j] > l[k]): 
            k += 1

        if(k>j): 
            count += k - j - 1

print(count)
# Original solution
import itertools
import sys


def main():
    readline = sys.stdin.readline
    readlines = sys.stdin.readlines
    sys.setrecursionlimit(10 ** 7)

    n = int(eval(input()))
    L = tuple(map(int, readline().split()))
    cnt = 0

    ls = tuple(itertools.combinations(L, 3))

    for l in ls:
        if sum(l) > max(l)*2:
            cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


# Optimized solution
import itertools
import sys


def main():
    input = sys.stdin.readline
    n = int(eval(input()))
    L = list(map(int, input().split()))
    cnt = 0

    ls = itertools.combinations(L, 3)

    for l in ls:
        if sum(l) > max(l)*2:
            cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()
# Original solution
from itertools import combinations


def check(l):
    for i in range(3):
        a = l[i % 3]
        b = l[(i + 1) % 3]
        c = l[(i + 2) % 3]
        if a >= b + c:
            return False
    return True


n = int(eval(input()))
l = list(map(int , input().split()))
cnt = 0
for v in combinations(l, 3):
    if check(v):
        cnt += 1
print(cnt)

# Optimized solution
from bisect import bisect_left


n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
cnt = 0
for i in range(n-2):
    a = l[i]
    for j in range(i+1, n-1):
        b = l[j]
        cnt += bisect_left(l, a+b) - j - 1
        # bisec_left(l, x)でlの中にxを挿入できる点を探す
print(cnt)
# Original solution
N = int(eval(input()))
L = list(map(int, input().split()))

L_sorted = sorted(L)

def bis(left, right, SrcList, value):
    if SrcList[left] >= value:
        return -1 # no results
    elif SrcList[right] < value:
        return -2 # all results
    while (left + 1 < right):
        mid = (left + right) // 2
        if SrcList[mid] < value:
            left = mid
        else:
            right = mid
    return left


count = 0
for i in range(0, N-2):
    for j in range(i+1,N-1):
        r = bis(j+1, N-1, L_sorted, L_sorted[i] + L_sorted[j])
        if r == -1:
            pass
        elif r == -2:
            count += ((N-j) * (N-j-1))//2
            break
        else:
            count += r-j
        

print(count)

# Optimized solution
from bisect import bisect_right

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

L_sorted = sorted(L)

count = 0
for i in range(N):  # longest stick
    for j in range(i):  # second longest stick
        r = bisect_right(L_sorted, L_sorted[i] - L_sorted[j])
        count += max(0, j - r)

print(count)
# Original solution
from bisect import bisect_right

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

L_sorted = sorted(L)

count = 0
for i in range(N):  # longest stick
    for j in range(i):  # second longest stick
        r = bisect_right(L_sorted, L_sorted[i] - L_sorted[j])
        count += max(0, j - r)

print(count)

# Optimized solution

from bisect import bisect_right

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

L_sorted = sorted(L)

count = 0
for i in range(N):  # longest stick
    for j in reversed(list(range(i))):  # second longest stick
        r = bisect_right(L_sorted, L_sorted[i] - L_sorted[j])
        if j <= r:
            break
        else:
            count += j - r

print(count)
# Original solution
n=int(eval(input()))
l=list(map(int,input().split()))
 
import bisect
 
ans=0
l.sort()
 
for i in range(n):
    a=l[i]#一番短い棒を確定
    for j in range(i+1,n):
        b=l[j]#二番目に短い棒を確定
        ind=bisect.bisect_left(l,a+b)#二辺の和と同じだったら耐えないので，left
        ans+=max(0,ind-(j+1))#三角形の成立条件と，一番長い棒であることを考える

print(ans)

# Optimized solution
import bisect
 

def main():
    n = int(eval(input()))
    ls = sorted(list(map(int, input().split())))
 
    ans = 0
    for i in range(n-1):
        for j in range(i+1, n):
            a = ls[i]
            b = ls[j]
            k = bisect.bisect_left(ls, a+b)
            if k > j:
                ans += k - j - 1
    print(ans)
 
 
if __name__ == "__main__":
    main()
# Original solution
import bisect

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

ans = 0
for i in range(2,n)[::-1]:
    for j in range(1,i)[::-1]:
        a = bisect.bisect_left(l, l[i] + l[j] - 1, 0, j-1)
        b = bisect.bisect_right(l, l[i] - l[j], 0, j-1)
        #print(l[i] + l[j], l[i] , l[j], a, l[i] - l[j], l[i] - l[j] < l[a], a, b, l[:j])
        if l[i] - l[j] < l[a]:
            ans += a - b + 1
print(ans)


# Optimized solution
import bisect

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

ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        ans += bisect.bisect_left(l,l[j]+l[i])-j-1
print(ans)
# Original solution
N=int(eval(input()))
Ln=list(map(int,input().split()))
Ln.sort(reverse=True)
Ans=0
 
for i in range(N-2):
    di=i+1
    for j in range(N-di-1):
        dj=di+j+1
        for k in range(N-dj):
            dk=dj+k+1
            a=Ln[di-1]
            b=Ln[dj-1]
            c=Ln[dk-1]
            if((a+b)>c)&((b+c)>a)&((c+a)>b) :
                Ans +=1
 
print(Ans)

# Optimized solution
N=int(eval(input()))
Ln=list(map(int,input().split()))
Ln.sort(reverse=True)
Ans=0
left=0
right=0
 
for i in range(N-2):
    di=i+1
    for j in range(N-di-1):
        dj=di+j+1
        A=Ln[di-1]
        B=Ln[dj-1]
        if (B+Ln[dj])<A : break
 
        right=N-1
        left=dj
        while left<=right :
            mid=int((right+left)/2)
            if (B+Ln[mid])>A :
                left=mid+1
            else :
                right=mid-1
        Ans+=(left-1)-(dj-1)
 
print(Ans)
# Original solution
import sys
N=int(eval(input()))
L=list(map(int,input().split()))
L.sort(reverse=True)
total = 0
def bisect_left_reverse(a, x):
    '''
    reverseにソートされたlist aに対してxを挿入できるidxを返す。
    xが存在する場合には一番左側のidxとなる。
    '''
    if a[0] <= x:
        return 0
    if x < a[-1]:
        return len(a)
    # 二分探索
    ok = len(a) - 1
    ng = 0
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if a[mid] <= x:
            ok = mid
        else:
            ng = mid
    return ok


for i in range(N):
  for j in range(i + 1, N):
    a = L[i] - L[j]
    total += max(bisect_left_reverse(L, a) - j - 1, 0)

print(total)


# Optimized solution
import sys
from bisect import bisect_left
N=int(eval(input()))
L=list(map(int,input().split()))
L.sort()
total = 0
for i in range(N):
  for j in range(i + 1, N):
    a = L[i] + L[j]
    total += max(bisect_left(L, a) - j - 1, 0)

print(total)
# Original solution
# -*- coding: utf-8 -*-
N = int(eval(input()))
L = list(map(int, input().split()))
tri = 0
ran = list(range(N-2))

for i in ran:
    for j in ran:
        for k in range(N-2-i-j):
            if ((L[i] + L[i+j+1]) > L[i+j+k+2]) and ((L[i] + L[i+j+k+2]) > L[i+j+1]) and ((L[i+j+k+2] + L[i+j+1]) > L[i]):
                tri += 1
print(tri)

# Optimized solution
# -*- coding: utf-8 -*-
N = int(eval(input()))
L = list(map(int, input().split()))

def main():
    tri = 0
    L.sort()
    for i in range(N-1,-1,-1): #range(初期値,終了条件,変化量)
        mn = 0
        sl = i-1
        while(mn<sl):
            if (L[mn] + L[sl]) > L[i]:
                tri += sl - mn
                sl -= 1
            else:
                mn += 1
    print(tri)
    
main()
# Original solution
import sys
sys.setrecursionlimit(10**6)

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

from itertools import combinations

l.sort()
ans = 0
seen = set()

for c in list(combinations(l,3)):
    if c not in seen:
        seen.add(c)
        if c[0]+c[1]>c[2] and c[1]+c[2]>c[0] and c[2]+c[0]>c[1]:
            ans += 1

print(ans)

# Optimized solution
import sys
sys.setrecursionlimit(10**6)

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

from itertools import combinations

l.sort()
ans = 0
combs = set(combinations(l,3))

for c in combs:
    if c[0]+c[1]>c[2] and c[1]+c[2]>c[0] and c[2]+c[0]>c[1]:
        ans += 1

print(ans)
# Original solution
N=int(eval(input()))
L=list(map(int,input().split()))
L.sort()
count = 0

for i in range(N):
  for j in range(i+1,N):
    summation = L[i] + L[j]
    subtract  = L[j] - L[i]
    D=L.copy()
    del D[j]
    del D[i]
    #E=[ D[k] for k in range(N) if k!= i and k!= j ]
    #求めるものはjよりも長くsummationよりも小さいもの
    ##summationより小さいかを二分探索
    high = N-3
    low = j-2
    if D[0] >= summation:
      upper = 0 #1つも満たさない
      #print(L[i],L[j],D,upper)
    elif D[-1] < summation:
      upper = N-1-j #すべてOK
    else:
      while high > low+1:
        mid =(high + low) // 2
        if D[mid] >= summation: #大きすぎ
          high = mid
          # mid = low
        else: #小さすぎかちょうど
          low = mid
          # mid =high 
      upper = high +1-j
    #print("summation",summation,D,upper)
    count += upper #-lower
print(count)  

# Optimized solution
from bisect import bisect_left
 
N = int(eval(input()))
L = sorted(list(map(int, input().split())))
 
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        a = L[i]
        b = L[j]
        idx = bisect_left(L, a + b)
        ans += idx - 1 - j
print(ans)
# Original solution
def main():
    N = int(eval(input()))
    L = [int(i) for i in input().split()]
    L.sort()
    L_pair = []
    for i in range(N):
        for j in range(i+1, N):
            L_pair.append((i, j))

    def is_ok(mid, i, j):
        if L[mid] < L[i] + L[j]:
            return True
        else:
            return False

    def binary_search_meguru(i, j):
        left = j
        right = N
        while right - left > 1:
            mid = left + ((right - left) // 2)
            if is_ok(mid, i, j):
                left = mid
            else:
                right = mid
        return right

    ans = 0
    for i, j in L_pair:
        r = binary_search_meguru(i, j)
        ans += r - (j + 1)
    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    from bisect import bisect_left
    N = int(eval(input()))
    L = [int(i) for i in input().split()]
    L.sort()
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            ab = L[i] + L[j]
            ri = bisect_left(L, ab)
            le = j + 1
            ans += ri - le

    print(ans)


if __name__ == '__main__':
    main()
# Original solution
def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(eval(input()))
    L = [int(i) for i in input().split()]
    L.sort()
    # from bisect import bisect_left
    ans = 0
    for i in range(2, N):
        # i番目を最長辺とする
        for j in range(i):
            for k in range(j+1, i):
                if L[j]+L[k] > L[i]:
                    ans += 1
    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(eval(input()))
    L = [int(i) for i in input().split()]
    L.sort()

    def is_ok(i, j, k):
        if L[j]+L[k] > L[i]:
            return True
        else:
            return False

    def binary_search_meguru(i, j):
        ng = -1
        ok = j
        while abs(ok - ng) > 1:
            mid = ng + (ok - ng) // 2
            if is_ok(i, j, mid):
                ok = mid
            else:
                ng = mid
        return ok
    ans = 0
    for i in range(2, N):
        # i番目を最長辺とする
        for j in range(i):
            k = binary_search_meguru(i, j)
            # print(i, j, k)
            ans += j-k
    print(ans)


if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))
dlist = list(map(int, input().split()))
dlist.sort(reverse=True)
sum = 0

count_b = 0
count_c = 0
for a in range(N):
    count_b += 1
    count_c = count_b
    for b in range(count_b, N):
        count_c += 1 
        for c in range(count_c, N):
            if dlist[a] < dlist[b] + dlist[c]:
                sum += 1
            else:
                break
print(sum)

# 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(i+1,N-1):
    ans+=bisect.bisect_left(L,L[i]+L[j])-j-1 # Code 1 
    # ans+=bisect.bisect_left(L,L[i]+L[j],j)-j-1 # Code 2 
print(ans)
# Original solution
N = int(eval(input()))
L = list(map(int, input().split()))

ans = 0
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):
            c = L[k]
            if a < b+c and b < c+a and c < a+b:
                ans += 1
print(ans)

# Optimized solution
import bisect

N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(1, N-1):
    for j in range(i+1, N):
        ans += i - bisect.bisect_right(L[:i], L[j]-L[i])
print(ans)
# Original 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[j+1:], l[i]+l[j])
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
import bisect
N = int(eval(input()))
Ls = list(map(int, input().split()))

sls = sorted(Ls)
count = 0
for i in range(N - 1):
    for j in range(i+1, N):
        cs = sls[j + 1:]
        a, b = sls[i], sls[j]
        count += bisect.bisect_left(cs, b + a)
print(count)

# Optimized solution
import bisect
N = int(eval(input()))
Ls = list(map(int, input().split()))

sls = sorted(Ls)
count = 0
for i in range(N - 1):
    for j in range(i+1, N):
        a, b = sls[i], sls[j]
        right = bisect.bisect_left(sls, b + a)
        count += right - j - 1
print(count)
# Original solution
n = int(eval(input()))
L = list(map(int,input().split()))
L.sort(reverse=True)

# print(L)
ans = 0
for i in range(n):
    # print(i)
    a = L[i]
    ci = 0
    for j in range(i+1,n-1):
        b = L[j]
        ci = n-1
        # print("ci",ci)
        while ci > j and b+L[ci] <= a:
            ci -= 1
        ans += ci-j
print(ans)



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

# print(L)
ans = 0
for i in range(n):
    # print(i)
    a = L[i]
    ci = n-1
    for j in range(i+1,n-1):
        b = L[j]
        ci = max(ci,j)
        # print("ci",ci)
        while ci > j and b+L[ci] <= a:
            ci -= 1
        ans += ci-j
print(ans)
# Original solution
n = int(eval(input()))
l = list(map(int, input().split()))

# comb = list(combinations(l, 3))

ans = 0
l.sort(reverse=True)
# for i in comb:
#     a = i[0]
#     b = i[1]
#     c = i[2]
#     if (a < b + c) and (b < c + a) and (c < a + b):
#         ans += 1

for i in range(n):
    for j in range(i + 1, n):
        a = l[i]
        b = l[j]
        for k in range(j + 1, n):
            c = l[k]
            # print(a, b, c)
            if (a < b + c) and (b < c + a) and (c < a + b):
                ans += 1

print(ans)


# Optimized solution
from bisect import bisect_left

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

ans = 0
l.sort()

for i in range(n):
    for j in range(i + 1, n):
        a = l[i]
        b = l[j]
        idx = bisect_left(l, a + b)
        # print(a, b, idx)

        ans += idx - (j + 1)


print(ans)
# Original solution
from bisect import bisect_right
N = int(eval(input()))
D = list(map(int, input().split()))
D.sort(reverse=False)

count = 0

for i in range(N):
    for j in range(i + 1, N - 1):
        target = int(D[N - i - 1]) - int(D[N - j - 1])
        l = D[:N - j - 1]
        count += len(l) - bisect_right(l, target)

print(count)


# Optimized solution
from bisect import bisect_right
N = int(eval(input()))
D = list(map(int, input().split()))
D.sort(reverse=False)

count = 0

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        # target = int(D[N - i - 1]) - int(D[N - j - 1])
        # l = D[:N - j - 1]
        # count += len(l) - bisect_right(l, target)
        ind = bisect_right(D, D[i] + D[j] - 1)
        count += max(ind - j - 1, 0)

print(count)
# Original solution
import itertools

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

total = 0
for v in itertools.combinations(l, 3):
    for j in itertools.combinations([0, 1, 2], 3):
        a, b, c = j[0], j[1], j[2]
        if abs(v[a] - v[b]) < v[c] < (v[a] + v[b]):
            total += 1
            break

print(total)


# Optimized solution
import bisect

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

total = 0
for a in range(n-2):
    for b in range(a+1, n-1):
        c = bisect.bisect_left(l, l[a] + l[b]) - b - 1
        total += c

print(total)