Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

n = int(input())
l = [int(i) for i in input().split()]

#l = list(set(l))
ans = 0
for i in range(len(l)-2):
    for j in range(i + 1, len(l) - 1):
        for k in range(j + 1, len(l)):
            if l[i] < l[j] + l[k] and l[j] < l[i] + l[k] and l[k] < l[i] + l[j]:
                ans += 1

print(ans)


### FIXED CODE ###

import bisect
import sys
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
ans = 0
for b in range(n):
    for a in range(b):
        tmp = l[a] + l[b]
        r = bisect.bisect_left(l, tmp)
        ll = b + 1
        ans += max(0, r - ll)
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
h,w=map(int,input().split())
a=[]
for i in range(h):
    a.append(list(map(int,input().split())))
b=[]
for i in range(h):
    b.append(list(map(int,input().split())))
dp=[[set([]) for i in range(w)] for j in range(h)]
dp[0][0].add(a[0][0]-b[0][0])
dp[0][0].add(b[0][0]-a[0][0])
for i in range(h):
    for j in range(w):
        if i==j==0:
            continue
        if i==0:
            for k in dp[i][j-1]:
                dp[i][j].add(k+a[i][j]-b[i][j])
                dp[i][j].add(k+b[i][j]-a[i][j])
        elif j==0:
            for k in dp[i-1][j]:
                dp[i][j].add(k+a[i][j]-b[i][j])
                dp[i][j].add(k+b[i][j]-a[i][j])
        else:
            for k in (dp[i][j-1]|dp[i-1][j]):
                dp[i][j].add(k+a[i][j]-b[i][j])
                dp[i][j].add(k+b[i][j]-a[i][j])             
#dp[h-1][w-1]
ans=10**10
for i in dp[h-1][w-1]:
    ans=min(ans,abs(i))
print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline
H,W=map(int,input().split())
a = [[] for _ in range(H)]
for i in range(H):
    a[i] = list(map(int, input().split()))
b = [[] for _ in range(H)]
for i in range(H):
    b[i] = list(map(int, input().split()))

for i in range(H):
    for j in range(W):
        a[i][j] =abs(a[i][j]-b[i][j])

dp = [[set() for _ in range(W)] for _ in range(H)]
dp[0][0].add(a[0][0])
for i in range(1,H):
    t = a[i][0]
    tmp = set()
    for k in dp[i-1][0]:
        tmp.add(k+t)
        tmp.add(abs(k-t))
    dp[i][0] = tmp
for j in range(1,W):
    t = a[0][j]
    tmp = set()
    for k in dp[0][j-1]:
        tmp.add(k+t)
        tmp.add(abs(k-t))
    dp[0][j] = tmp
for i in range(1,H):
    for j in range(1,W):
        t = a[i][j]
        tmp = set()
        for k in (dp[i-1][j] | dp[i][j-1]):
            tmp.add(k+t)
            tmp.add(abs(k-t))
        dp[i][j] = tmp
        dp[i-1][j-1] = set()

ls = list(dp[H-1][W-1])
print(min(ls))
### BUGGY CODE ###

def main():
    s = input()
    q = int(input())

    rule = 0
    for _ in range(q):
        query = input()
        if query[0] == '1':
            rule += 1
        else:
            if rule % 2 == 0:
                if query[2] == '1':
                    s = query[4] + s
                else:
                    s += query[4]
            else:
                if query[2] == '1':
                    s += query[4]
                else:
                    s = query[4] + s

    print(s if rule % 2 == 0 else s[::-1])


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    s = input()
    q = int(input())

    rule = 0
    pre, suf = '', ''
    for _ in range(q):
        query = input()
        if query[0] == '1':
            rule += 1
        else:
            if rule % 2 == 0:
                if query[2] == '1':
                    pre = query[4] + pre
                else:
                    suf += query[4]
            else:
                if query[2] == '1':
                    suf += query[4]
                else:
                    pre = query[4] + pre

    s = pre + s + suf
    print(s if rule % 2 == 0 else s[::-1])


if __name__ == '__main__':
    main()
### BUGGY CODE ###

import itertools
H,W,M = map(int,input().split())
lsx = [0] + [0]*H
lsy = [0] + [0]*W
lsxy = []
for i in range(M):
    x,y = map(int,input().split())
    lsx[x] += 1
    lsy[y] += 1
    lsxy.append((x,y))
maxx = max(lsx)
maxy = max(lsy)
lsmaxx = [i for i, x in enumerate(lsx) if x == maxx]
lsmaxy = [i for i, x in enumerate(lsy) if x == maxy]
lsp = list(itertools.product(lsmaxx,lsmaxy))
factor = 1
for i in lsp:
    if not i in lsxy:
        factor = 0
        break
print(maxx+maxy-factor)

### FIXED CODE ###

H,W,M = map(int,input().split())
lsx = [0] + [0]*H
lsy = [0] + [0]*W
lsxy = []
for i in range(M):
    x,y = map(int,input().split())
    lsx[x] += 1
    lsy[y] += 1
    lsxy.append([x,y])
maxx = max(lsx)
maxy = max(lsy)
cx = lsx.count(maxx)
cy = lsy.count(maxy)
al = cx*cy
for i in range(M):
    if lsx[lsxy[i][0]] == maxx and lsy[lsxy[i][1]] == maxy:
        al -= 1
if al == 0:
    factor = 1
else:
    factor = 0        
print(maxx+maxy-factor)
### BUGGY CODE ###

S = input()
Q = int(input())
for i in range(Q):
    q = input().split()
    if q[0] == '1':
        S = S[::-1]
    else:
        if q[1] == '1':
            S = q[2] + S
        else:
            S += q[2]
print(S)


### FIXED CODE ###

S = input()
Q = int(input())
qry = [input().split() for _ in range(Q)]
A = ''
B = ''
oq = 0
even = True
for q in qry:
    if q[0] == '1':
        even = not even
        if oq == '1':
            continue
    else:
        if even:
            if q[1] == '1':
                A = q[2] + A
            else:
                B += q[2]
        else:
            if q[1] == '1':
                B += q[2]
            else:
                A = q[2] + A
    oq = q

if even:
    print(A+S+B)
else:
    print(B[::-1]+S[::-1]+A[::-1])
### BUGGY CODE ###

n = int(input())
data = [int(x) for x in input().split()]

answer = 1

for x in data:
    answer *= x

if answer <= 1e+18:
    print(answer)
else:
    print(-1)

### FIXED CODE ###

n = int(input())
data = [int(x) for x in input().split()]

if 0 in data:
    print(0)
    exit(

    )
answer = 1

for x in data:
    answer *= x
    if answer > 1e+18:
        answer = -1
        break

print(answer)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))

import functools
import operator
prod = functools.partial(functools.reduce, operator.mul)
x = prod(a)

if x > 1000000000000000000:
    print(-1)
else:
    print(x)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))

x = 1
flag = False
INF = 10**18
if 0 in a:
    print(0)
else:
    for i in range(n):
        if flag == False:
            x *= a[i]
        if x > INF:
            flag = True
    
    if flag:
        print(-1)
    else:
        print(x)
### BUGGY CODE ###

N, M = map(int, input().split())

atb  = [list(map(int, input().split())) for _ in range(M)]

flg  = 0
#愚直にやる
for i in range(2, N, 1):

    #定期便ある?
    if [1, i] in atb:
        if [i, N] in atb:
            print("POSSIBLE")
            flg = 1
if flg==0:
    print("IMPOSSIBLE")

### FIXED CODE ###

N, M = map(int, input().split())

sa = set()
sb = set()


for i in range(M):

    a,b = map(int, input().split())

    if a==1:
        sa.add(b)
    elif b==N:
        sb.add(a)

print("POSSIBLE" if len(sa&sb)!=0 else "IMPOSSIBLE")
### BUGGY CODE ###

n = int(input())
s = [int(input()) for i in range(n)]
sum_list = [0]

for i in range(n):
    for j in range(len(sum_list)):
        sum_list.append(sum_list[j] + s[i])

sum_list.sort(reverse=True)
for i in sum_list:
    if i % 10 != 0:
        print(i)
        break
    else:
        pass
else:
    print(0)


### FIXED CODE ###

n = int(input())
s = []
for i in range(n):
    s.append(int(input()))

if sum(s) % 10 != 0:
    print(sum(s))
else:
    s.sort()
    for i in range(n):
        if s[i] % 10 == 0:
            pass
        else:
            print(sum(s) - s[i])
            break
    else:
        print(0)
### BUGGY CODE ###

n = int(input())
A = list(map(int, input().split()))
cnt = 0

B = [i + a for i, a in enumerate(A)]

C = [j - a for j, a in enumerate(A)]

for i, b in enumerate(B):
    for j, c in enumerate(C):
        if i >= j:
            continue
        elif b == c:
            cnt += 1
print(cnt)

### FIXED CODE ###

from collections import Counter
n = int(input())
A = list(map(int, input().split()))
cnt = 0

B = Counter(i + a for i, a in enumerate(A))
C = Counter(j - a for j, a in enumerate(A))
#print(B)
#print(C)
for k, v in B.items():
    cnt += C[k] * v
print(cnt)
### BUGGY CODE ###



N = int(input())
E = []
A = [[-1 for j in range(N+1)] for i in range(N+1)]
edges = [[] for i in range(N+1)]

for i in range(N-1):
  a, b = map(int, input().split())
  E.append((a,b))
  edges[a].append(b)
  edges[b].append(a)

def dfs(u):
  visited = set()
  stack = [(u, -1, -1)]
  mcolor = -1

  while stack:
    u, p, c = stack.pop()
    visited.add(u)

    next = 1
    for v in edges[u]:
      if v != p and v not in visited:
        if next == c:
          next += 1
        
        mcolor = max(mcolor, next)
        A[u][v] = next
        A[v][u] = next
        stack.append((v, u, next))
        next += 1
  
  return mcolor

print(dfs(1))

for edge in E:
  a, b = edge
  print(A[a][b])

### FIXED CODE ###


N = int(input())
edges = [[] for _ in range(N+1)]


for i in range(N-1):
  a, b = map(int, input().split())
  if i == 0:
    root = a
  edges[a].append((b, i))
  edges[b].append((a, i))

ans = [-1 for i in range(N-1)]
def dfs(u):
  flag = ["white"] * (N + 1)
  stack = [(u, -1, -1)]

  while stack:
    u, parent, color = stack.pop()
    flag[u] = "black"

    nextColor = 1
    for (next, index) in edges[u]:
      if next != parent and flag[next] != "black":
        if nextColor == color:
          nextColor += 1
        stack.append((next, u, nextColor))
        ans[index] = nextColor
        nextColor += 1

dfs(root)

print(max(ans))

for a in ans:
  print(a)
### BUGGY CODE ###

import sys
import numpy as np

n, k = map(int, input().split())

p = np.array([list(map(int, input().split()))]).reshape(-1)

sum_max = 0
index_max = -1
for i in range(n-k+1):
    mx = np.sum(p[i:i+k])
    if mx > sum_max:
        sum_max = mx
        index_max = i
print(str((sum_max+k) / 2))

### FIXED CODE ###

import sys
import numpy as np

n, k = map(int, input().split())

p = np.array([list(map(int, input().split()))]).reshape(-1)

sum_max = p[:k].sum()
mx = sum_max
index_max = -1
for i in range(1, n-k+1):
    mx += p[i+k-1]
    mx -= p[i-1]
    if mx > sum_max:
        sum_max = mx
        index_max = i
print(str((sum_max+k) / 2))
### BUGGY CODE ###

def main():

    s = input()
    q = int(input())
    query = [input().split() for _ in range(q)]
    ctn = query.count(["1"]) % 2 == 1

    new_query = []
    flag = 0
    for q in query:
        if len(q) == 1:
            if flag == 0:
                flag = 1
            else:
                flag = 0
        else:
            q += [flag]
            new_query.append(q)

    for q in new_query:
        if q[-1] == 0:
            if q[1] == "1":
                s = q[2] + s
            else:
                s += q[2]
        else:
            if q[1] == "1":
                s += q[2]
            else:
                s = q[2] + s

    if ctn:
        print(s[::-1])
    else:
        print(s)

main()

### FIXED CODE ###

from collections import deque

def main():

    s = deque(input())
    q = int(input())

    flag = 0
    query = []

    for _ in range(q):
        temp = input().split()
        if len(temp) == 1:
            flag += 1
        else:
            query.append(temp + [flag%2])

    for q in query:
        if q[-1] == 0:
            if q[1] == "1":
                s.appendleft(q[2])
            else:
                s.append(q[2])
        else:
            if q[1] == "1":
                s.append(q[2])
            else:
                s.appendleft(q[2])

    if flag % 2 == 1:
        print("".join(list(s)[::-1]))
    else:
        print("".join(s))

main()
### BUGGY CODE ###

n,m = map(int,input().split())
ab = [ list(map(int,input().split())) for i in range(n)]
# print(ab)
ab.sort(reverse=True)
# print(ab)
# print(len(ab))
from heapq import heappush
from heapq import heappop
# from heapq import heapify

heap = [0]*m

ans = 0
for i in reversed(range(m)):
    # print(ab)
    # print("i={}".format(i))
    if i < 0:
        break
    else:
        # print("n={}".format(n))
        for j in range(n):
            if (ab[j][0]+i) > m:
                pass
            else:
                heappush(heap, -(ab[j][1]))
                ab[j][1] = 0
        # print(heap)
    ans += heappop(heap)
    # print(ans)

# print(ans)
print(abs(ans))

### FIXED CODE ###

n,m = map(int,input().split())
ab = [ list(map(int,input().split())) for i in range(n) ]
# print(ab)
ab.sort()
# print(ab)
import heapq
heap = []
ans = 0
i = 0
for day in reversed(range(m)):
    while i<n and ab[i][0]==(m-day):
        heapq.heappush(heap,-ab[i][1])
        i += 1
    if len(heap) > 0:
        ans += -heapq.heappop(heap)
    # print(day,i,ans,heap)
print(ans)
### BUGGY CODE ###

k,s = map(int,input().split())
cnt = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if(x+y+z)==s:
                cnt += 1
print(cnt)

### FIXED CODE ###

k,s = map(int,input().split())
cnt = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if(z>=0 and z<=k):
            cnt += 1
print(cnt)
### BUGGY CODE ###


import numpy as np

def submit():
    n, k = map(int, input().split())
    hlist = np.array([int(input()) for _ in range(n)])

    hlist.sort()
    min_diff = float('inf')
    for i in range(0, n - k + 1):
        choices = hlist[i : i + k]
        maxh = np.max(choices)
        minh = np.min(choices)

        if maxh - minh < min_diff:
            min_diff = maxh - minh

    print(min_diff)
        

if __name__ == "__main__":
    submit()

### FIXED CODE ###


def submit():
    n, k = map(int, input().split())
    hlist = [int(input()) for _ in range(n)]

    hlist.sort()
    min_diff = float('inf')
    for i in range(0, n - k + 1):
        minh = hlist[i]
        maxh = hlist[i + k - 1]
        if maxh - minh < min_diff:
            min_diff = maxh - minh

    print(min_diff)
        

if __name__ == "__main__":
    submit()
### BUGGY CODE ###

S = input()
N = len(S)
C = [[1]*N,[0]*N,[0]*N]
j = 0
while C[0] != C[2]:
  k1 = j%3
  k2 = (j+1)%3
  C[k2] = [0]*N
  for i in range(N):
    if S[i] == "R":
      C[k2][i+1] += C[k1][i]
    else:
      C[k2][i-1] += C[k1][i]
  j += 1
if j % 2 == 0:
  print(" ".join(map(str,C[k2])))
else:
  print(" ".join(map(str,C[k1])))


### FIXED CODE ###

S = input()
N = len(S)
C = [0]*N
count = 0
idxl,idxm,idxr = 0,0,0
for i in range(N-1):
  if S[i] == "R" and S[i+1] == "L":
    idxm = i
  if (S[i] == "L" and S[i+1] == "R") or i == N-2:
    idxr = i if i < N-2 else N-1 #正しい？
    count = (idxr-idxl)+1
    nr = (idxm-idxl)+1
    nl = (idxr-idxm)
#    print(i,count,idxm,idxr)
    if count%2 == 0:
      C[idxm] = C[idxm+1] = count//2
    else:
      m = count//2
      if (nr > nl and nr%2 == 1) or (nr < nl and nl%2 == 0):
        C[idxm] = m+1
        C[idxm+1] = m
      else:
        C[idxm] = m
        C[idxm+1] = m+1
#    print(i,idxl,idxm,idxr)
    idxl = i+1
print(" ".join(map(str,C)))
### BUGGY CODE ###

from collections import Counter
n=int(input())
s=str(input())
a=Counter(s)
aa=list(a.values())
aa.sort()
aa=aa[::-1]
m=len(aa)
ans=0
#print(aa)
for i in range(1,2**m):
    z=format(i,'b').zfill(m)
    #print(z)
    ans1=1
    for j in range(m):
        if aa[j]==1:
            ans+=ans1%(10**9+7)
            break
        if int(z[j])>0:
            ans1*=aa[j]*int(z[j])%(10**9+7)
    else:
        ans+=ans1%(10**9+7)
print(ans%(10**9+7))

### FIXED CODE ###

from collections import Counter
n=int(input())
s=str(input())
a=Counter(s)
aa=list(a.values())
#print(aa)
ans=1
for i in aa:
    ans*=(i+1)%(10**9+7)
print((ans-1)%(10**9+7))
### BUGGY CODE ###

import bisect


def count_pair(A, x):
    # A内のペアで積がxより小さいものの個数
    N = len(A)
    cnt = 0
    for n in range(N - 1):
        if A[n] < 0:
            y = x // A[n]
            # n+1番以降でyより大きいものの個数
            cnt += N - bisect.bisect_right(A, y, lo=n + 1)
        elif A[n] > 0:
            y = -(-x // A[n])
            # n+1番以降でyより小さいものの個数
            cnt += bisect.bisect_left(A, y, lo=n + 1) - (n + 1)
        else:  # A[n]==0
            if x > 0:
                cnt += N - n - 1
    return cnt


# count_pair(x)<Kをみたすxの最大値を求める
N, K = map(int, input().split())
* A, = map(int, input().split())
A.sort()
max_A = max(A)
min_A = min(A)
inf = max(max_A**2, min_A**2, abs(max_A*min_A))
l, r = -inf, inf
while r - l > 1:
    c = (l + r) // 2
    if count_pair(A, c) < K:
        l = c
    else:
        r = c
print(l)


### FIXED CODE ###

import numpy as np


def count_pair(x):
    # A内のペアで積がxより小さいものの個数
    # まず(i,j)と(j,i)を重複して数える
    cnt = 0
    # A[i]<0なる各iに対してA[j]>x/A[i]なるjの個数
    cnt += (N-np.searchsorted(A, x//A_nega, side='right')).sum()
    if x > 0:
        # 各iに対してA[j]=0なるjの個数
        cnt += len(A_zero)*N
    # A[i]>0なる各iに対してA[j]<x/A[i]なるjの個数
    cnt += np.searchsorted(A, -(-x//A_posi), side='left').sum()
    # i=jを除いてから2で割る
    cnt = (cnt-(A**2 < x).sum())//2
    return cnt


# count_pair(x)<Kをみたすxの最大値を二分探索で求める
N, K = map(int, input().split())
* A, = map(int, input().split())
A = np.array(A)
A = np.sort(A)
A_posi = A[A > 0]
A_zero = A[A == 0]
A_nega = A[A < 0]
inf = 10**18+1
l, r = -inf, inf
while r - l > 1:
    c = (l + r) // 2
    if count_pair(c) < K:
        l = c
    else:
        r = c
print(l)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from collections import defaultdict
N = int(input())
T = [input()[::-1].strip() for i in range(N)]
R,S = zip(*[(t[:-1],t[-1]) for t in T])


tt = defaultdict(lambda : defaultdict(int))

for word in T:
    w = ""
    t = word
    for s in word:
        for u in set(t):
            tt[w][u] += 1
        t = t[1:]
        w += s

ans = 0
for word in T:
    if len(word) > 1:
        w,t = word[:-1],word[-1]
    else:
        w,t = "",word
    ans += tt[w][t] - 1

print(ans)



### FIXED CODE ###

import sys
import string
input = sys.stdin.readline
from collections import defaultdict
N = int(input())
T = [input()[::-1].strip() for i in range(N)]

#N = 100
#M = 10000
#import random
#import string
#T = [''.join(random.choices(string.ascii_lowercase, k=random.randint(M,M))) for i in range(N)]

class TrieTree:
    class Node:
        def __init__(self):
            #self.clue = defaultdict(int)
            self.clue = [0]*26
            self.ch = defaultdict(TrieTree.Node)
            self.cnt = 0
            self.end = False

    def __init__(self):
        self.root = self.Node()

    def register(self,word):
        node = self.root
        for w in word:
            node.cnt += 1
            node = node.ch[w]
        node.cnt += 1
        node.end = True
    
    def prefix(self, word):
        node = self.root
        for w in word:
            if w not in node.ch:
                return False
            else:
                node = node.ch[w]
        return node

tt = TrieTree()
for word in T:
    tt.register(word)

route = []

st = [tt.root]
while st:
    node = st.pop()
    route.append(node)
    st.extend(node.ch.values())

f = lambda c : ord(c)-97
for node in route[::-1]:
    for c,nnode in node.ch.items():
        for i,v in enumerate(nnode.clue):
            node.clue[i] += v
        node.clue[f(c)] += nnode.cnt - nnode.clue[f(c)]

ans = 0
for word in T:
    pre = word[:-1]
    last = word[-1]
    node = tt.prefix(pre)
    if not node:
        continue
    ans += node.clue[f(last)] - 1
    
print(ans)
### BUGGY CODE ###

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

base = sum(A)

Q = int(input())

for i in range(Q):
  B, C = map(int, input().split())
  # Aに現れるBの個数xがわかればよい
  x = A.count(B)
  base += x*(C-B)
  print(base)
  A = [a if a != B else C for a in A] 

  

### FIXED CODE ###

from collections import defaultdict

N = int(input())
A = tuple(map(int, input().split()))
dic = defaultdict(int)

for a in A:
  dic[a] += 1
    
Q = int(input())

base = sum(A)

for i in range(Q):
  B, C = map(int, input().split())
  tmp = dic[B]
  dic[B] = 0
  dic[C] += tmp
  base += (C-B)*tmp
  print(base)
### BUGGY CODE ###

#54 ABC134E

n=int(input())
a=[int(input()) for _ in range(n)]

import heapq
i=0
heap=[-a[0]]
res=[]
import bisect
for i in range(1,n):
	t=bisect.bisect_right(heap,-a[i])
	if t==0:
		heapq.heapreplace(heap,-a[i])
	elif t>=len(heap):
		heapq.heappush(heap,-a[i])
	else:
		heap[t]=-a[i]
		heapq.heapify(heap)

	#print(heap,t)
print(len(heap))

### FIXED CODE ###

#54 ABC134E

n=int(input())
a=[int(input()) for _ in range(n)]

def LIS(L):
    from bisect import bisect
    seq=[]
    for i in L:
        pos=bisect(seq,-i)
        if len(seq)<=pos:
            seq.append(-i)
        else:
            seq[pos]=-i
    return len(seq)

print(LIS(a))
### BUGGY CODE ###

def main():

    n, k = map(int, input().split())
    p = list(map(int, input().split()))

    ex = [0]
    for x in p:
        ex.append(ex[-1] + 1/x * (sum(list(range(1, x+1)))))

    ans = 0
    for i in range(k, n+1):
        ans = max(ans, ex[i] - ex[i-k])

    print(ans)

main()

### FIXED CODE ###

def main():

    n, k = map(int, input().split())
    p = list(map(int, input().split()))

    ex = [0]
    for x in p:
        ex.append(ex[-1] + (x+1)/2)

    ans = 0
    for i in range(k, n+1):
        ans = max(ans, ex[i] - ex[i-k])

    print(ans)

main()
### BUGGY CODE ###

import itertools
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

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

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

for l in ls:
    if l[0] < l[1]+l[2] and l[1] < l[2]+l[0] and l[2] < l[0]+l[1]:
        cnt += 1

print(cnt)


### FIXED CODE ###

import bisect
import sys

input = sys.stdin.readline

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

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

print(cnt)
### BUGGY CODE ###

from collections import*
M=lambda:map(int,input().split())
n,q=M()
s=[[]for _ in range(n)]
for i in range(n-1):
  a,b=M()
  s[a-1].append(b-1)
  s[b-1].append(a-1)
p=[0]*n
for i in range(q):
  a,b=M()
  p[a-1]+=b
v=[1]+[0]*(n-1)
d=deque([(0,0)])
while d:
  b,c=d.popleft()
  c+=p[b]
  p[b]=c
  for i in s[b]:
    if v[i]:continue
    v[i]=1
    d.append((i,c))
print(*p)

### FIXED CODE ###

import sys;input=sys.stdin.readline
from collections import deque
M=lambda:map(int,input().split())
n,q=M()
s=[[]for _ in range(n)]
for i in range(n-1):
  a,b=M()
  s[a-1].append(b-1)
  s[b-1].append(a-1)
p=[0]*n
for i in range(q):
  a,b=M()
  p[a-1]+=b
v=[1]+[0]*(n-1)
d=deque([(0,0)])
while d:
  b,c=d.popleft()
  c+=p[b]
  p[b]=c
  for i in s[b]:
    if v[i]:continue
    v[i]=1
    d.append((i,c))
print(*p)
### BUGGY CODE ###

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

step_max = 0

for i in H:
    step = 0
    for k in range(len(H)-1):
        if H[k] >= H[k+1]:
            step += 1
        else:
            break
    if step > step_max:
        step_max = step
    del H[0]

print(step_max)

### FIXED CODE ###

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

count = 0
step = [0]*len(H)

for i in range(len(H)-1):
    if H[i]>=H[i+1]:
        count += 1
    else:
        count = 0
    step[i+1] = count

print(max(step))