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

n,m = map(int,input().split())
x = list(map(int,input().split()))
x = sorted(x)
d = []
for i in range(len(x)-1):
    d.append(x[i+1]-x[i])
if n==1:
    print(x[-1]-x[0])
elif n>=len(x):
    print(0)
else:
    for i in range(n-1):
        d.remove(max(d))
    print(sum(d))

### FIXED CODE ###

n,m = map(int,input().split())
x = list(map(int,input().split()))
x = sorted(x)
d = []
for i in range(len(x)-1):
    d.append(x[i+1]-x[i])
d = sorted(d)
if n==1:
    print(x[-1]-x[0])
elif n>=len(x):
    print(0)
else:
    dis = 0
    for i in range(n-1):
        dis+=d[-i-1]
    print(sum(d)-dis)
### BUGGY CODE ###

import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from  collections import defaultdict
import bisect
from functools import reduce
def main():
    def comb(n, r):
        numerator = reduce(lambda x, y: x * y % mod, [n - r + k + 1 for k in range(r)])
        denominator = reduce(lambda x, y: x * y % mod, [k + 1 for k in range(r)])
        return numerator * pow(denominator, mod - 2, mod) % mod
    mod = 10 ** 9 + 7
    N, K = MI()
    if K >= N - 1:
        ans = comb(2 * N - 1, N - 1)
        print(ans)
    else:
        N_r = pow(N, mod - 2, mod)
        ans = N * (N - 1) % mod
        if K >= 2:
            ans += 1
        for i in range(2, K + 1):
            ans += ((comb(N, i) ** 2 % mod) * ((N - i) % mod) * N_r) % mod
            ans %= mod
        print(ans)

if __name__ == "__main__":
    main()


### FIXED CODE ###

import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from  collections import defaultdict
import bisect
from functools import reduce
def main():
    def comb(n, r):
        numerator = reduce(lambda x, y: x * y % mod, [n - r + k + 1 for k in range(r)])
        denominator = reduce(lambda x, y: x * y % mod, [k + 1 for k in range(r)])
        return numerator * pow(denominator, mod - 2, mod) % mod
    mod = 10 ** 9 + 7
    N, K = MI()
    if K >= N - 1:
        ans = comb(2 * N - 1, N - 1)
        print(ans)
    else:
        N_r = pow(N, mod - 2, mod)
        ans = N * (N - 1) % mod
        add = N * (N - 1) % mod
        for i in range(2, K + 1):
            a = (N - i + 1) % mod
            b = (a - 1) % mod
            c = pow(i, mod - 2, mod)
            d = pow(c, 2, mod)
            add = ((((add * a) % mod * b) % mod) * d) % mod
            ans += add
            ans %= mod
        if K >= 2:
            ans += 1
            ans %= mod
        print(ans)

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

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

answer="Yes"

for i in range(N):
    if i>=1:
        for j in range(i+1):
            if H[j]>H[i]+1:
                answer="No"
                break
            else:
                pass
print(answer)

### FIXED CODE ###

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

answer="Yes"

for i in range(1,N,):
    if H[N-i]>=H[N-i-1]:
        pass
    else:
        H[N-i-1]-=1
        if H[N-i]<H[N-i-1]:
            answer="No"

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

n = int(input())
al = list(map(int, input().split()))
l = []
for i in range(n):
    l.append(al.index(i + 1) + 1)
print(*l, sep = ' ')

### FIXED CODE ###

n = int(input())
al = list(map(int, input().split()))
cl = []
for j in range(n):
    cl.append([al[j], j + 1])
cl.sort()
bl = []
for i in range (n):
    bl.append(cl[i][1])
print(*bl, sep=' ')
### BUGGY CODE ###

import bisect

N, M = [int(i) for i in input().split()]
alist = [int(i) for i in input().split()]
alist.sort()
inputs = [[int(i) for i in input().split()] for j in range(M)]
inputs.sort(key=lambda x:x[1])

for i in inputs:
    if alist[0] > i[1]:
        continue
    elif alist[i[0]-1] < i[1]:
        alist = [i[1]] * i[0] + alist[i[0]:]
    else:
        limit=bisect.bisect_left(alist, i[1])
        alist = [i[1]] * limit + alist[limit:]
    alist.sort()

print(sum(alist))




### FIXED CODE ###

import bisect

N, M = [int(i) for i in input().split()]
alist = [int(i) for i in input().split()]
alist.sort()
inputs = [[int(i) for i in input().split()] for j in range(M)]
inputs.sort(key=lambda x:x[1], reverse=True)

for i in range(N):
    if len(inputs) == 0:
        break
    if inputs[0][1] > alist[i]:
        alist[i] = inputs[0][1]
        inputs[0][0] -= 1
        if inputs[0][0] == 0:
            inputs.pop(0)
    else:
        break
print(sum(alist))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
import bisect
N,Q = (int(x) for x in input().split())

stop_arr = []
for _ in range(N):
    S,T,X = (int(x) for x in input().split())
    stop_arr.append((S,T,X))
Q_arr = []
for _ in range(Q):
    Q_arr.append(int(input()))

stop_arr.sort(key=lambda x:x[2], reverse=True)

ans_arr = [-1]*Q

for s,t,x in stop_arr:
    q_start = bisect.bisect_left(Q_arr, s-x)
    q_stop = bisect.bisect_left(Q_arr, t-x)
    for i in range(q_start, q_stop):
        ans_arr[i] = x

for a in ans_arr:
    print(a)


### FIXED CODE ###

import bisect

N,Q = (int(x) for x in input().split())

stop_arr = [tuple(map(int, input().split())) for _ in range(N)]
Q_arr = [int(input()) for _ in range(Q)]

stop_arr_ind = list(range(N))
stop_arr_ind.sort(key=lambda x:stop_arr[x][2])
# stop_arr.sort(key=lambda x:x[2], reverse=True)
ans_arr = [-1]*Q
skip_arr = [-1]*(Q+1)

def update_skip(skip_arr, x):
    if skip_arr[x] == -1:
        return x
    x_dest = update_skip(skip_arr, skip_arr[x])
    skip_arr[x] = x_dest
    return x_dest

for i in stop_arr_ind:
    s,t,x = stop_arr[i]
    q_start = bisect.bisect_left(Q_arr, s-x)
    q_stop = bisect.bisect_left(Q_arr, t-x)
    l = q_start
    while l < q_stop:
        if skip_arr[l] == -1:
            skip_arr[l] = q_stop
            ans_arr[l] = x
            l += 1
        else:
            l = update_skip(skip_arr, l)

print(*ans_arr, sep="\n")
### BUGGY CODE ###

# ABC066 C - pushpush
# 2019/10/29

n ,*a = map(int, open(0).read().split())
# print(n, a)

b=[]
if n%2 == 0:
    for i in range(n):
        if i%2!=0:
            b.insert(0,a[i])
        else:
            b.append(a[i])
#         print(i, b)
else:
    for i in range(n):
        if i%2==0:
            b.insert(0,a[i])
        else:
            b.append(a[i])
#         print(i, b)
        
# print(b)
print(" ".join([str(i) for i in b]))

### FIXED CODE ###

# dequeのappendとappendleftはO(1)、O(1)

from collections import deque

n ,*a = map(int, open(0).read().split())
b = deque()

for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])
 
if n % 2 == 1:
    b.reverse()
 
print(*b)
### BUGGY CODE ###

import itertools
N,M=map(int,input().split())
A,B=[0]*M,[0]*M
for i in range(M):
    A[i],B[i]=map(int,input().split())

res=0
for p in itertools.permutations(range(M),N-1):
    path=[]
    if A[p[0]]==1:
        path.append(A[p[0]])
    else:
        continue
    path.append(B[p[0]])
    for i in range(len(p)-1):
        if A[p[i+1]]==path[-1]:
            if not B[p[i+1]] in path:
                path.append(B[p[i+1]])
            else:
                break
        elif B[p[i+1]]==path[-1]:
            if not A[p[i+1]] in path:
                path.append(A[p[i+1]])
            else:
                break
        else:
            break
    else:
        path.sort()
        if path==list(range(1,N+1)):
            res+=1
print(res)

### FIXED CODE ###

import itertools
N,M=map(int,input().split())
edges=[]
for i in range(M):
    edges.append(list(map(int,input().split())))

res=0
for i in itertools.permutations(range(2,N+1),N-1):
    path=[1]+list(i)
    check=[sorted(path[i:i+2]) in edges for i in range(len(path)-1)]
    if not False in check:
        res+=1
print(res)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = []
for i in range(n):
  ans.append(a.index(i+1)+1)
print(*ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = []
A = []
for i in range(n):
  ans.append((a[i],i+1))
ans.sort()
for i in range(n):
  A.append(ans[i][1])
print(*A)
### BUGGY CODE ###

n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
for j in range(n):
    ma=0
    for h in range(n):
        if(h!=j):
            if(ma<a[h]):
                ma=a[h]
    print(str(ma))  


### FIXED CODE ###

while True:
    n=int(input())
    if(2<=n<=200000):
        break
a=[]
for i in range(n):
        a.append(int(input()))
ma=a[0]
b=0
for j in range(1,n):
    if(ma==a[j]):
        b=a[j]
    if(ma<a[j]):
        ma=a[j]
        continue
    if(b<a[j]):
        b=a[j]
for l in range(n):
    if(a[l]!=ma):
        print(str(ma))
    else:
        print(str(b))
### BUGGY CODE ###

n,k=map(int,input().split())
b=[int(input()) for _ in range(n)]
dp=[0]*(max(b)+1)
c=max(b)
for i in range(n):
    dp[b[i]]=max(dp[b[i]],max(dp[max(0,b[i]-k):min(c+1,b[i]+k+1)])+1)
print(max(dp))


### FIXED CODE ###

N,K=map(int,input().split())
class SegTree:
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])
    def update(self, k, x):
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        res = self.ide_ele
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res
ide_ele = 0
b=[int(input()) for _ in range(N)]
c=max(b)
def segfunc(x,y):
    return max(x,y)
seg=SegTree([0]*(c+6),segfunc,ide_ele)
for i in range(N):
    a=b[i]
    seg.update(a,seg.query(max(0,a-K),min(c+2,a+K+1))+1)
print(seg.query(0,c+3))
### BUGGY CODE ###

import numpy as np
h,w,m = map(int,input().split())
bombX = [0]*h
bombY = [0]*w
bomb = []
maxX = maxY = 0
for i in range(m):
    i,j = map(lambda x:int(x)-1, input().split())
    bomb.append((i,j))
    bombX[i] += 1
    bombY[j] += 1
    maxX = max(maxX,bombX[i])
    maxY = max(maxY,bombY[j])
maxX_index = list(i for i in range(h) if bombX[i] == maxX)
maxY_index = list(i for i in range(w) if bombY[i] == maxY)
for i in maxX_index:
    for j in maxY_index:
        if (i,j) in bomb: continue
        print(maxX+maxY)
        exit()
print(maxX+maxY-1)

### FIXED CODE ###

h,w,m = map(int,input().split())
bombX = [0]*h
bombY = [0]*w
bomb = set()
maxX = maxY = 0
for i in range(m):
    i,j = map(lambda x:int(x)-1, input().split())
    bomb.add((i,j))
    bombX[i] += 1
    bombY[j] += 1
    maxX = max(maxX,bombX[i])
    maxY = max(maxY,bombY[j])
maxX_index = list(i for i in range(h) if bombX[i] == maxX)
maxY_index = list(i for i in range(w) if bombY[i] == maxY)
for i in maxX_index:
    for j in maxY_index:
        if (i,j) in bomb: continue
        print(maxX+maxY)
        exit()
print(maxX+maxY-1)
### BUGGY CODE ###

N = int(input())
P = list(map(int,input().split()))
Nflag = 0
count = 0
for i in range(N,1,-1):
    for j in range(i-1,0,-1):
        if P[i-1]>P[j-1]:
            Nflag = 1
            break
    if Nflag == 0:
        count+=1
    Nflag = 0
print(count+1)

### FIXED CODE ###

N = int(input())
P = list(map(int,input().split()))
Nflag = 0
count = 0
tmp = float("inf")
for i in P:
    if i<tmp:
        tmp=i
    else:
        count+=1
print(N-count)
### BUGGY CODE ###

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

adic=dict()

for ai in a:
    if ai in adic:
        adic[ai]+=1
    else:
        adic[ai]=1
        
q=int(input())
b=[0]*(q+1)
c=[0]*(q+1)
for i in range(q):
    b[i],c[i]=map(int,input().split())
    
#print(adic)    
for i in range(q):
    if b[i] in adic and c[i] in adic:
        adic[c[i]]=adic[c[i]]+adic[b[i]]
        del adic[b[i]]
    elif b[i] in adic and (not c[i] in adic):
        adic[c[i]]=adic[b[i]]
        del adic[b[i]]
#        adic[b[i]]=0
#    print(i,adic)
    asum=0
    for i,ad in adic.items():
        asum+=i*ad
    print(asum)
    

### FIXED CODE ###

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

adic=dict()

for ai in a:
    if ai in adic:
        adic[ai]+=1
    else:
        adic[ai]=1
        
q=int(input())
b=[0]*(q)
c=[0]*(q)
bc=[[0]*2 for i in range(q)]
for i in range(q):
    bc[i]=map(int,input().split())
    
asum=0
for i,ad in adic.items():
    asum+=i*ad
    
#print(adic)    
for bi,ci in bc:
    if bi in adic and ci in adic:
        asum-=bi*adic[bi]
        adic[ci]=adic[ci]+adic[bi]
        asum+=ci*adic[bi]
        del adic[bi]
    elif bi in adic and (not ci in adic):
        asum-=bi*adic[bi]
        adic[ci]=adic[bi]
        asum+=ci*adic[bi]
        del adic[bi]
#    print(i,adic)
    print(asum)
### BUGGY CODE ###

import numpy as np

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

checker = []

detacheck = [0 for _ in range(N)]


#for AB in ABs:
#    checker[AB[0] - 1].add(AB[1])
#    checker[AB[1] - 1].add(AB[0])

tmp = 0
for AB in ABs:
#    print(detacheck)
    if(detacheck[AB[0] -1] == 0 and detacheck[AB[1] -1] == 0):
        checker.append(set(AB))
        tmp += 1
        detacheck[AB[0] - 1] = tmp
        detacheck[AB[1] - 1] = tmp


    elif(detacheck[AB[0] -1] == 0 or detacheck[AB[1] -1] == 0):
#        print(detacheck[AB[0] -1] , detacheck[AB[1] -1])
        checker[max(detacheck[AB[0] -1]-1,detacheck[AB[1] -1]-1)].add(AB[0])
        checker[max(detacheck[AB[0] -1]-1,detacheck[AB[1] -1]-1)].add(AB[1])

        detacheck[AB[0] - 1] = max(detacheck[AB[0] - 1],detacheck[AB[1] - 1])
        detacheck[AB[1] - 1] = max(detacheck[AB[0] - 1],detacheck[AB[1] - 1])

    else:
#        print(AB[0], AB[1])
        checker[detacheck[AB[0] -1]-1] = checker[detacheck[AB[0] -1]-1].union(checker[detacheck[AB[1] -1]-1])
        for i in checker[detacheck[AB[1] -1]-1]:
            detacheck[i-1] =  detacheck[AB[0] - 1]
#    print(checker)

ans = 1

for anscheck in checker:
#    print(anscheck, len(anscheck))
    ans = max(ans, len(anscheck))


print(ans)

### FIXED CODE ###

import numpy as np

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


par = [i for i in range(N+1)]
size = [1 for _ in range(N+1)]

def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x]) #経路圧縮
        return par[x]
def same(x,y):
    return find(x) == find(y)
def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    par[x] = y
    size[y] = size[x] + size[y]
    size[x] = 0

for AB in ABs:
    unite(AB[0],AB[1])

print(max(size))
### BUGGY CODE ###

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

pos = [pow(2, i) - a[i] for i in range(n+1)]
for i in range(n):
    pos[i+1] = pos[i] * 2 - a[i+1]

for i in range(n+1):
    if pos[i] < 0:
        print(-1)
        exit()

cnt = a[-1]
memo = 0
for i in range(n-1, -1, -1):
    cnt += min(pos[i], memo + a[i+1]) + a[i]
    memo = min(pos[i], memo + a[i+1])


print(cnt)

### FIXED CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))

pos = [0 for i in range(n+1)]
pos[0] = 1 - a[0]
for i in range(n):
    pos[i+1] = pos[i] * 2 - a[i+1]

for i in range(n+1):
    if pos[i] < 0:
        print(-1)
        exit()

cnt = a[-1]
memo = 0
for i in range(n-1, -1, -1):
    cnt += min(pos[i], memo + a[i+1]) + a[i]
    memo = min(pos[i], memo + a[i+1])


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

N, M = map(int, input().split())
A = list(map(int, input().split()))
operation = []
ans = 0

for _ in range(M):
    t = tuple(map(int, input().split()))
    operation.append(t)

operation.sort(key=lambda x: x[1], reverse=True)
A.sort()

while A and operation:
    if A[-1] >= operation[0][1]:
        ans += A[-1]
        A.pop(-1)
    else:
        cnt = 0
        for i in range(operation[0][0]):
            if len(A) == i or A[i] > operation[0][1]:
                cnt = i
                break
        else:
            cnt = operation[0][0]
        for _ in range(cnt):
            A.pop(0)
        ans += cnt * operation[0][1]
        operation.pop(0)

ans += sum(A)

print(ans)


### FIXED CODE ###

from collections import deque

N, M = map(int, input().split())
A = list(map(int, input().split()))
operation = []
ans = 0

for _ in range(M):
    t = tuple(map(int, input().split()))
    operation.append(t)

operation.sort(key=lambda x: x[1], reverse=True)
A.sort()
A = deque(A)
operation = deque(operation)

while A and operation:
    if A[-1] >= operation[0][1]:
        ans += A[-1]
        A.pop()
    else:
        cnt = 0
        for i in range(operation[0][0]):
            if len(A) == i or A[i] > operation[0][1]:
                cnt = i
                break
        else:
            cnt = operation[0][0]
        for _ in range(cnt):
            A.popleft()
        ans += cnt * operation[0][1]
        operation.popleft()

ans += sum(A)

print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

ans = 0
while m > 0:
    mina = min(a)
    idx = a.index(mina)
    bn = b[idx]
    if m < bn:
        ans += mina * m
        m = 0
    else:
        ans += mina * bn
        m -= bn
    a.pop(idx)
    b.pop(idx)

print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
a.sort(key=lambda x: x[0])
ans = 0
for i in a:
    if i[1] > m:
        ans += i[0] * m
        break
    else:
        ans += i[0] * i[1]
        m -= i[1]
print(ans)
### BUGGY CODE ###

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

R = N
for i in range(0,N):
    t = A[i]
    for j in A[i+1:N]:
        if not (t & j):
            R += 1
            t += j
        else:
            break
print(R)


### FIXED CODE ###

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

result = 0
Right = 0
tmp = 0
for left in range(N):
    for right in range(Right,N):
        if not (tmp & A[right]):
            tmp += A[right]
            Right = right + 1
        else:
            break
    tmp -= A[left]
    result += Right - left
print(result)
### BUGGY CODE ###

N,S,Q,*K = open(0).read().split()
N = int(N)
Q = int(Q)
K = map(int,K)
for k in K:
  C = [0]*N
  M = [0]*N
  CMS = [0]*N
  SDMC = 0
  SMC = 0
  SC = 0
  Ms = 0
  for i in range(k):
    if S[i]=='C':
      CMS[i] = Ms
    elif S[i]=='M':
      Ms += 1
      M[i] = 1
  for i in range(k,N):
    Ms -= M[i-k]
    if S[i]=='C':
      CMS[i] = Ms
    elif S[i]=='M':
      Ms += 1
      M[i] = 1
  for i in range(N-1,N-1-k,-1):
    if S[i]=='C':
      SC += 1
      C[i] = 1
    elif S[i]=='M':
      SMC += SC
    elif S[i]=='D':
      SDMC += SMC
  for i in range(N-1-k,-1,-1):
    SC -= C[i+k]
    SMC -= CMS[i+k]
    if S[i]=='C':
      SC += 1
      C[i] = 1
    elif S[i]=='M':
      SMC += SC
    elif S[i]=='D':
      SDMC += SMC
  print(SDMC)


### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
S = np.frombuffer(readline().rstrip(),'S1')
Q = int(readline())
query = map(int,read().split())

isD = S == b'D'
isM = S == b'M'
isC = S == b'C'

cumD = isD.cumsum(dtype=np.int64)
cumM = isM.cumsum(dtype=np.int64)

def F(K):
    """
    ・Cごとに数える。
    ・そのためには(i-K,i] 内のDMの個数を調べる（負インデックスには関係ない文字があると思っておく）
    ・区間内のDの個数、Mの個数が取得できれば、差分が取得できるので最後に累積和
    """
    # (i-K,i]内のDの個数、Mの個数
    D = cumD.copy(); D[K:] -= cumD[:-K]
    M = cumM.copy(); M[K:] -= cumM[:-K]
    # 最後がMのとき、Dの個数分増える
    DM = isM * D
    # 左端のDを捨てるとき、Mの個数分減る
    DM[K:] -= isD[:-K] * M[K-1:-1]
    np.cumsum(DM,out=DM)
    # Cごとに集計
    return DM[isC].sum()

print('\n'.join(str(F(K)) for K in query))
### BUGGY CODE ###

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

result = [0] * n
for x in range(0,n):
    for i in range(x, n-1):
        if h[i] < h[i+1]:
            break
        else:
            result[x] += 1
print(max(result))

### FIXED CODE ###

n = int(input())
h = list(map(int,input().split()))
result = []
count = 0
for x in range(0,n-1):
    if h[x] >= h[x+1]:
        count += 1
    else:
        result.append(count)
        count = 0
result.append(count)
print(max(result))
### BUGGY CODE ###

#ABC 127 C Prison
N,M= map(int,input().split())
ans=None
for i in range(M):
    L,R= map(int,input().split())
    tmp=set([i for i in range(L,R+1)])
    if ans is None:
        ans=tmp
    else:
        ans=ans & tmp
print(len(ans))

### FIXED CODE ###

#ABC 127 C Prison
N,M= map(int,input().split())
MIN=0
MAX=N
for i in range(M):
    L,R= map(int,input().split())
    MAX=min(MAX,R)
    MIN=max(MIN,L)
ans =MAX-MIN+1
if ans <0:
    print(0)
else:
    print(ans)
### BUGGY CODE ###

def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

Q = int(input())

for i in range(Q):
    a, b = map(int,input().split())
    ans = 0
    while a <= b:
        if is_prime(a):
            if is_prime((a + 1) // 2):
                ans += 1
        a += 1
    print(ans)



### FIXED CODE ###

import math
def is_prime(x):
    if x < 2: return False  # 2未満に素数はない
    if x == 2 or x == 3 or x == 5: return True  # 2,3,5は素数
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False  # 2,3,5の倍数は合成数

    # ためし割り: 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    pri = 7
    step = 4
    while pri <= math.sqrt(x):
        if x % pri == 0: return False

        pri += step
        step = 6 - step

    return True

Q = int(input())

prime = [0] * 100002
prime[0] = 0
prime[1] = 0
prime[2] = 0
num = 3

while num < 100002:
    prime[num] = prime[num - 1]
    if is_prime(num) and is_prime((num + 1) // 2):
        prime[num] += 1
    num += 1
ans = []

for i in range(Q):
    a, b = map(int, input().split())
    ans.append(prime[b] - prime[a-1])

for i in range(Q):
    print(ans[i])
### BUGGY CODE ###

N=int(input())
import numpy as np
A=np.zeros(N)
B=np.zeros(N)
for i in range(0,N):
  A[i],B[i] = map(int,input().split())

for b in B:
  if np.sum(A[B<=b])>b:
    print('No')
    break
else:
  print('Yes')

### FIXED CODE ###

import sys
import bisect
import numpy as np
input = sys.stdin.readline
N=int(input())
A=[0]*N
B=[0]*N
for i in range(N):
    A[i],B[i]=[int(x) for x in input().split()]
matrix = np.vstack((np.array(A),np.array(B)))
matrix = matrix[:, np.argsort(matrix[1])]
time=0
capacity=0
for a,b in zip(matrix[0],matrix[1]):
    capacity += (b-time) - a
    time = b
    if capacity <0:
        print('No')
        sys.exit()
    #print(capacity,a,b)
print('Yes')
### BUGGY CODE ###

import math

K = int(input())
summ = 0

for i in range(1, K + 1):
    for j in range(1, K + 1):
        for k in range(1, K + 1):
            tmp = math.gcd(i, j)
            summ+=math.gcd(tmp,k)

print(summ)

### FIXED CODE ###

import math
 
K = int(input())
summ = 0
 
for i in range(1, K + 1):
    for j in range(1, K + 1):
        for k in range(1, K + 1):
            tmp = math.gcd(i, j)
            summ+=math.gcd(tmp,k)
 
print(summ)