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

import sys
input=lambda: sys.stdin.readline().rstrip()
import collections
D=collections.defaultdict(int)
r,c,k=map(int,input().split())
for _ in range(k):
	ri,ci,v=map(int,input().split())
	ri-=1
	ci-=1
	D[ri*10**5+ci]=v

DP=[[[0]*4 for _ in range(c+1)] for i in range(r+1)]
for i in range(r+1):
	for j in range(c+1):
		v=D[i*10**5+j]
		if v!=0:
			DP[i][j][1]=max(DP[i-1][j])+v
		for ii in range(4):
			DP[i][j][0]=max(DP[i][j][0],DP[i-1][j][ii])
			if v!=0:
				DP[i][j][1]=max(DP[i][j][1],DP[i-1][j][ii]+v)
			DP[i][j][ii]=max(DP[i][j][ii],DP[i][j-1][ii])
			if v!=0 and ii!=0:
				DP[i][j][ii]=max(DP[i][j][ii],DP[i][j-1][ii-1]+v)
		
ans=max(DP[r-1][c-1])
print(ans)



### FIXED CODE ###

import sys
input=lambda: sys.stdin.readline().rstrip()

r,c,k=map(int,input().split())
D=[[0]*c for _ in range(r)] 
for _ in range(k):
	ri,ci,v=map(int,input().split())
	ri-=1
	ci-=1
	D[ri][ci]=v

DP0=[[0]*(c+1) for i in range(r+1)]
DP1=[[0]*(c+1) for i in range(r+1)]
DP2=[[0]*(c+1) for i in range(r+1)]
DP3=[[0]*(c+1) for i in range(r+1)]
for i in range(r):
	for j in range(c):
		v=D[i][j]
		if v!=0:
			DP1[i][j]=max(DP0[i-1][j],DP1[i-1][j],DP2[i-1][j],DP3[i-1][j])+v

		DP0[i][j]=max(DP0[i][j],DP0[i-1][j],DP1[i-1][j],DP2[i-1][j],DP3[i-1][j])
		if v!=0:
			DP1[i][j]=max(DP1[i][j],DP0[i-1][j]+v,DP1[i-1][j]+v,DP2[i-1][j]+v,DP3[i-1][j]+v)
		DP0[i][j]=max(DP0[i][j],DP0[i][j-1])
		DP1[i][j]=max(DP1[i][j],DP1[i][j-1])
		DP2[i][j]=max(DP2[i][j],DP2[i][j-1])
		DP3[i][j]=max(DP3[i][j],DP3[i][j-1])
		if v!=0:
			DP1[i][j]=max(DP1[i][j],DP0[i][j-1]+v)
			DP2[i][j]=max(DP2[i][j],DP1[i][j-1]+v)
			DP3[i][j]=max(DP3[i][j],DP2[i][j-1]+v)
		
ans=max(DP0[r-1][c-1],DP1[r-1][c-1],DP2[r-1][c-1],DP3[r-1][c-1])
print(ans)
### BUGGY CODE ###

def binary(x):
    '''40桁の2進数表記の作成'''

    k = 40
    s = ''
    for i in reversed(range(k)):
        s += str(x // 2 ** i)
        x %= 2 ** i

    return s

# 未知のxkを既知のkkに置き換える
# k += 1 として、x < k を満たす
# この時、xの未知の40桁のいくつかを、既知のkで置き換える
n, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

ck = [0 for i in range(40)]
for i in a:
    ab = binary(i)
    for j in range(40):
        ck[j] += int(ab[j])


k1b = binary(k + 1)

for i in reversed(range(len(k1b))):
    if k1b[-i-1] == '1':
        lenk = i
        break

fx = []
for i in reversed(range(lenk + 1)):
    x = ''
    for j in reversed(range(40)):
        if j > i:
            x += str(int(k1b[-j-1]))
        elif j == i:
            if k1b[-j-1] == '1':
                x += str(0)
            else:
                break
        else:
            if ck[-j-1] * 2 > n:
                x += str(0)
            else:
                x += str(1)

    if len(x) == 40:
        fx_temp = 0
        for k in range(40):
            if x[-k-1] == '1':
                fx_temp += 2 ** k * (n - ck[-k-1])
            else:
                fx_temp += 2 ** k * ck[-k-1]
        fx.append(fx_temp)

print(max(fx))


### FIXED CODE ###

# bit演算という方法がある、ビット演算子
# a & b 1,1で1
# a | b 1,1, 1,0, 0,1で1
# a ^ b xor
# ~a ビット反転
# << 左シフト
# >> 右シフト
# 未知のxkを既知のkkに置き換える
# k += 1 として、x < k を満たす
# この時、xの未知の40桁のいくつかを、既知のkで置き換える
# 注意として、xはkより大きくなってはいけない

n, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

ck = [0 for i in range(40)]
for i in a:
    for j in range(40):
        if i>>j & 1:
            ck[j] += 1

fx = []
for i in range(40):

    if (k+1)>>i & 1 == 0:
        continue

    ans = 0
    for j in range(40):
        if j > i:
            if ((k+1)>>j) & 1:
                ans += (1<<j) * (n-ck[j])
            else:
                ans += (1<<j) * ck[j]
        elif j == i:
            ans += (1<<j) * ck[j]
        else:
            if ck[j] * 2 > n:
                ans += (1<<j) * ck[j]
            else:
                ans += (1<<j) * (n-ck[j])

    fx.append(ans)

print(max(fx))
### BUGGY CODE ###

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

turn = 0
for _ in range(q):
    query = input()
    if len(query) == 1:
        turn += 1
    else:
        two, f, c = query.split()
        if f == '1':
            if turn % 2 == 0:
                s = ''.join([c, s])
            else:
                s = ''.join([s, c])
        else:
            if turn % 2 == 0:
                s = ''.join([s, c])
            else:
                s = ''.join([c, s])

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

### FIXED CODE ###

import sys
input = sys.stdin.readline

s = input().strip()
q = int(input())
query = [list(input().strip().split()) for _ in range(q)]

left = ''
right = ''
t = False
for ls in query:
    if len(ls) == 1:
        t = not t
    else:
        two, f, c = ls
        if f == '1':
            if t:
                right += c
            else:
                left += c
        else:
            if t:
                left += c
            else:
                right += c

if t:
    print(right[::-1] + s[::-1] + left)
else:
    print(left[::-1] + s + right)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(100001)
N, M, K = map(int, input().split())

All = set()
F_candidate = [0] * N
F, B = {}, {}
for i in range(N):
    F[i] = set()
    B[i] = set()
    All.add(i)

for _ in range(M):
    x, y = map(int, input().split())
    F[x - 1].add(y - 1)
    F[y - 1].add(x - 1)

for _ in range(K):
    x, y = map(int, input().split())
    B[x - 1].add(y - 1)
    B[y - 1].add(x - 1)


def dfs(v, visited):

    visited.add(v)

    for n in F[v]:
        if n in visited:
            continue
        dfs(n, visited)


for i in range(N):

    if i in All:
        C = set()   # connected graph
        dfs(i, C)
        All = All - C
        for j in C:
            D = C - {j}
            D = D - B[j]
            D = D - F[j]
            F_candidate[j] = len(D)

for i in range(N):
    print(F_candidate[i], end='')
    if i != N - 1:
        print(' ', end='')
    else:
        print('')


### FIXED CODE ###

import sys
sys.setrecursionlimit(100001)
N, M, K = map(int, input().split())

label = [-1] * N
n_label = [0] * N

F, B = {}, {}
for i in range(N):
    F[i] = set()
    B[i] = set()

for _ in range(M):
    x, y = map(int, input().split())
    F[x - 1].add(y - 1)
    F[y - 1].add(x - 1)

for _ in range(K):
    x, y = map(int, input().split())
    B[x - 1].add(y - 1)
    B[y - 1].add(x - 1)


def dfs(v, lab):
    if label[v] != -1:
        return 0
    label[v] = lab
    n_label[lab] += 1
    for n in F[v]:
        dfs(n, lab)
    return 1


# labeling
count = 0
for i in range(N):
    count += dfs(i, count)
n_label = n_label[:count]

# calc friend candidate
blocked = 0
for b in B[0]:
    if label[b] == label[0]:
        blocked += 1
print(n_label[label[0]] - 1 - len(F[0]) - blocked, end='')
for i in range(1, N):
    print(' ', end='')
    blocked = 0
    for b in B[i]:
        if label[b] == label[i]:
            blocked += 1
    print(n_label[label[i]] - 1 - len(F[i]) - blocked, end='')
print('')
### BUGGY CODE ###

# -*- coding: utf-8 -*-
INF = 10**10
n = int(input())
a = [int(_) - (i + 1) for i, _ in enumerate(input().split())]
a.sort()

grief = INF
for b in range(a[0], a[-1] + 1):
    tmp = sum([abs(ai - b) for ai in a])
    if tmp < grief:
        grief = tmp

print(grief)


### FIXED CODE ###

# -*- coding: utf-8 -*-
n = int(input())
a = [int(_) - (i + 1) for i, _ in enumerate(input().split())]

# INF = 10**10
# grief = INF
# for b in set(a):
#     tmp = sum([abs(ai - b) for ai in a])
#     if tmp < grief:
#         bb = b
#         grief = tmp

# print(grief)  # running time limit error

a.sort()
med = a[len(a) // 2]
grief = sum([abs(ai - med) for ai in a])
print(grief)
### BUGGY CODE ###

import sys
import bisect as bi
import math
from collections import defaultdict as dd
import heapq
import itertools
input=sys.stdin.readline
from random import randint
##import numpy as np
##sys.setrecursionlimit(10**7)
mo=10**9+7
def cin():
    return map(int,sin().split())
def ain():            
    return list(map(int,sin().split()))
def sin():
    return input()
def inin():
    return int(input()) 
def lcm(a,b): 
    return (a*b) // math.gcd(a,b) 
for _ in range(1):
    n=inin()
    l=ain()
    f1,f2=0,0
    gc=lc=l[0]
    for i in range(1,n):
        gc=math.gcd(gc,l[i])
        if(math.gcd(l[i],lc)!=1):
            f1=1
        lc=lcm(lc,l[i])
    if(gc!=1):print("not coprime")
    else:
        if(f1):
            print("setwise coprime")
        else:
            print("pairwise coprime")
        
        
    
    
    

 
    
    
    
    
        
        
    
    
    
    


    




##def msb(n):n|=n>>1;n|=n>>2;n|=n>>4;n|=n>>8;n|=n>>16;n|=n>>32;n|=n>>64;return n-(n>>1) #2 ki power
##def pref(a,n,f):             
##    pre=[0]*n
##    if(f==0):         ##from beginning
##        pre[0]=a[0]
##        for i in range(1,n):
##            pre[i]=a[i]+pre[i-1]
##    else:              ##from end
##        pre[-1]=a[-1]
##        for i in range(n-2,-1,-1):
##            pre[i]=pre[i+1]+a[i]
##    return pre
##maxint=10**24 
##def kadane(a,size): 
##    max_so_far = -maxint - 1
##    max_ending_here = 0
##       
##    for i in range(0, size): 
##        max_ending_here = max_ending_here + a[i] 
##        if (max_so_far < max_ending_here): 
##            max_so_far = max_ending_here 
##  
##        if max_ending_here < 0: 
##            max_ending_here = 0   
##    return max_so_far
##def power(x, y):
##    if(y == 0):return 1
##    temp = power(x, int(y / 2))%mo
##    if (y % 2 == 0):return (temp * temp)%mo 
##    else:
##        if(y > 0):return (x * temp * temp)%mo 
##        else:return ((temp * temp)//x )%mo


### FIXED CODE ###

import math
N=int(input())
m=10**6+1
M=[0]*m
g=0
for i in map(int,input().split()):M[i]+=1;g=math.gcd(g,i)
if g>1:print('not coprime')
elif all(sum(M[i::i])<=1 for i in range(2,m)):print('pairwise coprime')
else:print('setwise coprime')
### BUGGY CODE ###

MOD = 10**9 + 7


def gcd(a, b):
    while b != 0:
        a, b = b, a - (a // b) * b

    return a


def lcm(iterable):
    a = iterable[0]

    for b in iterable:
        a = a * b // gcd(a, b)

    return a


def inv_mod(x):
    return pow(x, MOD - 2)


def pow(x, n):
    res = 1
    while n > 0:
        if n & 1 == 1:
            res = res * x % MOD
        x = x * x % MOD
        n >>= 1

    return res


def main():
    N = int(input())
    an = list(map(int, input().split()))

    lcm_an = lcm(an)

    ans = 0
    for a in an:
        ans = (ans + lcm_an * inv_mod(a)) % MOD

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import functools

MOD = 10**9 + 7


def lcm(a, b) -> int:
    c, d = a, b
    while d != 0:
        c, d = d, c % d
    return a // c * b


def inv_mod(x):
    return pow(x, MOD - 2)


def pow(x: int, n: int) -> int:
    res = 1
    while n > 0:
        if n & 1 == 1:
            res = res * x % MOD
        x = x * x % MOD
        n >>= 1

    return res


def main():
    N = int(input())
    an = list(map(int, input().split()))

    lcm_an = functools.reduce(lcm, an)
    lcm_an %= MOD

    ans = 0
    for a in an:
        ans = (ans + lcm_an * inv_mod(a)) % MOD

    print(ans)


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

from functools import reduce
input()
print(a if (a:=reduce(lambda x,y:int(x)*int(y), input().split()))<=1e18 else -1)

### FIXED CODE ###

input()
s=1
for a in map(int,input().split()):
  if a==0:s=0;break
  if s>0:s*=a
  if s>1e18:s=-1
print(s)
### BUGGY CODE ###

N, X, M = map(int,input().split())
ans = 0
ls = [X%M] + [-1]*(M+1)
for i in range(N):
    a = ls[i]
    ls[i+1] = pow(a,2,M)
    if i+1 < N and ls[i+1] in ls[:i]:
        b = ls[i+1]
        L = ls.index(b)
        R = i
        len_roop = R - L + 1
        p = (N - L) // len_roop
        q = (N - L) % len_roop
        break
else:
    for i in range(N):
        ans += ls[i]
    print(ans)   
    exit()
    
sum_roop = 0        
for i in range(L, R+1):
    sum_roop += ls[i]
    
sum_edge = 0
for i in range(L, L+q):
    sum_edge += ls[i] 
    
for i in range(L):
    ans += ls[i]
else:
    ans += sum_roop * p + sum_edge        
    
print(ans) 

### FIXED CODE ###

N, X, M = map(int,input().split())
ans = 0
ls = [X%M] + [-1]*(M+1)
ls_app = [0]*(M+1)

for i in range(N):
    a = ls[i]
    ls_app[a] = i
    ls[i+1] = pow(a,2,M)
    if i+1 < N and ls_app[ls[i+1]] != 0:
        b = ls[i+1]
        L = ls.index(b)
        R = i
        len_roop = R - L + 1
        p = (N - L) // len_roop
        q = (N - L) % len_roop
        break
else:
    for i in range(N):
        ans += ls[i]
    print(ans)   
    exit()
    
sum_roop = 0        
for i in range(L, R+1):
    sum_roop += ls[i]
    
sum_edge = 0
for i in range(L, L+q):
    sum_edge += ls[i] 
    
for i in range(L):
    ans += ls[i]
else:
    ans += sum_roop * p + sum_edge        
    
print(ans)
### BUGGY CODE ###

import numpy as np
import fractions 
#from functools import reduce
import functools

MOD = 10**9+7


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

    # def lcm(x, y):
    #     return x * y // fractions.gcd(x, y)
        
    
    # x = functools.reduce(lcm, A, 1)

    x=1
    for a in A:x*=a//fractions.gcd(x, a)

    
    b = sum(x//a%MOD for a in A)
    print(b%MOD)
if __name__== "__main__":
    main()


### FIXED CODE ###

import fractions 
#from functools import reduce
import functools

MOD = 10**9+7


def main():
    # N = int(input())
    # A = list(map(int, input().split()))
    N, *A = map(int, open(0).read().split())
            
    x = 1
    for a in A:
        x *= a //  fractions.gcd(x, a)
        
    b = sum(x//a for a in A)
    print(b%MOD)
    
if __name__== "__main__":
    main()
### BUGGY CODE ###

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

    mod = 10**9 + 7
    answer = 0

    for i in range(0, n-1):
        sum_other = sum(a[i+1:])
        answer += a[i] * sum_other
        if answer >= mod:
            answer %= mod

    print(answer)


'''
    for i in range(n):
        sum_sub = 0
        for j in range(i+1, n):
            sum_sub += a[j]
            if sum_sub >= mod:
                sum_sub %= mod
        answer += a[i] * sum_sub
        if answer >= mod:
            answer %= mod
    print(answer)
'''

'''
    for i in range(n):
        for j in range(i+1, n):
            answer += a[i] * a[j]
            if answer >= mod:
                answer %= mod
    print(answer)
'''

if __name__ == "__main__":
    main()


### FIXED CODE ###

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

    mod = 10**9 + 7
    answer = 0
    sum_a = sum(a) % mod

    for i in range(n):
        sum_a = sum_a - a[i]
        answer += a[i] * sum_a
        answer %= mod

    print(answer)


'''
    for i in range(n):
        sum_sub = 0
        for j in range(i+1, n):
            sum_sub += a[j]
            if sum_sub >= mod:
                sum_sub %= mod
        answer += a[i] * sum_sub
        if answer >= mod:
            answer %= mod
    print(answer)
'''

'''
    for i in range(n):
        for j in range(i+1, n):
            answer += a[i] * a[j]
            if answer >= mod:
                answer %= mod
    print(answer)
'''

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

N = int(input())
alist = [int(input()) for x in range(N)]
l = []
for num in alist:
        if num in l:
                l.remove(num)
        else:
                l.append(num)

print(len(l))

### FIXED CODE ###

N = int(input())
alist = sorted([int(input()) for x in range(N)])

tmpNum = alist[0]
cnt = 1
ans = 0
for i in range(1, N):
	num = alist[i]
	if tmpNum == num:
		cnt = cnt + 1
		if i == N-1 and cnt % 2 != 0:
			ans = ans + 1
	else:
		if cnt % 2 != 0:
			ans = ans + 1
		tmpNum = num
		cnt = 1
		if i == N-1:
			ans = ans + 1

if len(alist) == 1:
	ans = ans + 1


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

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

for i in range(3):
    n = [1, 0, -1]
    if L[i] <= L[3]:
        maxres += L[i] * n[i]
        L[3] -= L[i]
    else:
        for j in range(L[3]):
            maxres += n[i]
            L[3] -= 1
print(maxres)

### FIXED CODE ###

L = list(map(int, input().split()))
n = [1, 0, -1]
maxres = 0

for i in range(3):
    if L[3] == 0:
        break
    maxres += L[i] * n[i]
    L[3] -= L[i]
    #print(L[3])
    if L[3] < 0:
        maxres -= abs(L[3]) * n[i]
        break
print(maxres)
### BUGGY CODE ###

n = int(raw_input())
a = [raw_input() for i in xrange(n)]
b = map(int,a)
for i in xrange(n):
    ml = [b[j] for j in xrange(n) if j != i]
    print max(ml)

### FIXED CODE ###

import copy
def calcmax(a,b,fst,scd,n):
    for i in xrange(n):
        if fst == a[i]:
            count = i

    for i in xrange(n):
        if count == i:
            print scd
        else:
            print fst

if __name__ == '__main__':
    n = int(raw_input())
    a = [int(raw_input()) for i in xrange(n)]
    print("")

    fst = max(a)

    b = copy.deepcopy(a)
    b.remove(fst)

    scd = max(b)

    calcmax(a,b,fst,scd,n)
### BUGGY CODE ###

import numpy as np

N, K = map(int, input().split())
A = np.array([0] + list(map(int, input().split())))
mod = A % K
mod_cum = mod.cumsum()
#print(mod_cum)
answer = 0
for i in range(1, N+1):
    #print(i, (mod_cum[i:] - mod_cum[:-i]) % K)
    answer += ((mod_cum[i:] - mod_cum[:-i]) % K == i).sum()
#Anをチェック
print(answer)    

### FIXED CODE ###

import sys
import numpy as np
from collections import defaultdict

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
A = np.array([1] + lr())
A = (A-1) % K
N += 1
Acum = (A.cumsum() % K).tolist()
d = defaultdict(int)
answer = 0
for i, x in enumerate(Acum):
    answer += d[x]
    d[x] += 1
    if i >= K-1:
        d[Acum[i-(K-1)]] -= 1

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

import math

n=int(input())

sum=0
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      y=list([i,j,k])
      z=len(y)//3
      for h in range(0,z):
        x=math.gcd(y[0],y[1])
        p=math.gcd(x,y[2])
        sum=sum+p
print(sum)

### FIXED CODE ###

import math

n=int(input())

sum=0
for i in range(1,n+1):
  for j in range(1,n+1):
      x=math.gcd(i,j)
      for h in range(1,n+1):
        p=math.gcd(x,h)
        sum=sum+p
print(sum)
### BUGGY CODE ###

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

idx = 1
idx_count = 0
idx_set = []
for i in range(N):
  if idx != B[i]:
    tmp1 = int(idx_count*(idx_count-1)/2)		# 同一の整数を持つボールの組合せ数
    tmp2 = int((idx_count-1)*(idx_count-2)/2)	# 同一の整数を持つボールを1つ除いたときの組合せ数
    idx_set.append([idx, tmp1, tmp2])
    idx_count = 0
    idx = B[i]
  idx_count+=1
if idx_count != 0:
  tmp1 = int(idx_count*(idx_count-1)/2)		# 同一の整数を持つボールの組合せ数
  tmp2 = int((idx_count-1)*(idx_count-2)/2)	# 同一の整数を持つボールを1つ除いたときの組合せ数
  idx_set.append([idx, tmp1, tmp2])

idx_sum_set = []
for i in range(len(idx_set)):
  tmp = 0
  for j in range(len(idx_set)):
    if i == j:
      tmp += idx_set[j][2]
    else:
      tmp += idx_set[j][1]
  idx_sum_set.append([idx_set[i][0],tmp])
  
for i in range(N):
  for j in range(len(idx_sum_set)):
    if A[i] == idx_sum_set[j][0]:
      print(idx_sum_set[j][1])
"""
for i in range(N):
  tmp = 0
  for j in range(len(idx_set)):
    if A[i] == idx_set[j][0]:
      tmp += idx_set[j][2]
    else:
      tmp += idx_set[j][1]
  print(tmp)
"""



### FIXED CODE ###

import numpy as np
N = int(input())
A = list(map(int, input().split()))
B = np.zeros(N+1)

for i in range(N):
  B[A[i]]+=1
#print(B)

all_c = 0
for i in range(1,N+1):
  all_c += int(B[i]*(B[i]-1)/2)			# 同一の整数を持つボールの組合せ数
for i in range(N):
  if B[A[i]] != 0:
    print(int(all_c-(B[A[i]]-1)))
### BUGGY CODE ###

n,m=map(int,input().split())
x=list(map(int,input().split()))
if n==1:
    print(max(x)-min(x))
elif m==1 or n>=m:
    print(0)
else:
    goukei=0
    l=[0]
    i=0
    x.sort()
    a=0
    b=0
    if m>1:
        while i<m-1:
            a=x[i]
            b=x[i+1]
            goukei+=b-a
            l.append(b-a)
            i+=1
    i=0
    l.sort()
    while i<n-1:
        a=max(l)
        goukei-=a
        l.remove(a)
        i+=1
        if l==[]:
            break
    print(goukei)

### FIXED CODE ###

n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
if n==1:
    print(max(x)-min(x))
elif m==1 or n>=m:
    print(0)
else:
    x.sort()
    goukei=0
    l=[0]
    for i in range(m-1):
        goukei+=x[i+1]-x[i]
        l.append(x[i+1]-x[i])
    i=0
    l.sort()
    for i in range(n-1):
        goukei-=l[-1-i]
    print(goukei)
### BUGGY CODE ###

N = int(input())
H = list(map(int,input().split()))
ans = 0
cnt = 0
for i in range(N):
    ans = max(ans,cnt)
    cnt = 0
    for j in range(N-i-1):
        if H[i+j] >= H[i+j+1]:
            cnt += 1
        else:
          break    
print(ans)

### FIXED CODE ###

N = int(input())
H = list(map(int,input().split()))
ans = 0
cnt = 0
for i in range(N-1):
      if H[i] >= H[i+1]:
          cnt += 1
      else:
          ans = max(ans,cnt)
          cnt = 0
      if i+2 == N:
        print(max(ans,cnt))
        exit()
print(ans)
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()
nums = [list(map(int, input().split())) for i in range(q)]
for m in nums:
    s2 = s[m[0]-1:m[1]]
    s2 = s2.split("AC")
    print(len(s2)-1)


### FIXED CODE ###

n, q = map(int, input().split())
s = input()
ac = [0]*n
for i in range(n-1):ac[i+1] = ac[i] + (s[i:i+2]=="AC")
for i in range(q):
    l,r=map(int,input().split())
    print(ac[r-1]-ac[l-1])
### BUGGY CODE ###

import sys
from collections import defaultdict
s=list(input())

for i in range(len(s)):
  subs=s[i:]
  dic=defaultdict(int)
  for k in range(len(subs)):
    dic[subs[k]]+=1
    if k>=1 and dic[subs[k]]>(k+1)//2:
      print(i+1,i+k+1)
      sys.exit(0)
else:
  print(-1,-1)

### FIXED CODE ###

import sys
s=list(input())

for i in range(1,len(s)):
  if s[i-1]==s[i]:
    print(i,i+1)
    sys.exit(0)
  
for i in range(2,len(s)):
  if s[i-2]==s[i]:
    print(i-1,i+1)
    sys.exit(0)
    
print(-1,-1)
### BUGGY CODE ###

N, C = map(int, input().split())
d = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(int, input().split())) for _ in range(N)]

ans = float("inf")
for c_i in range(C):
    for c_j in range(C):
        if c_i == c_j:
            continue
        for c_k in range(C):
            if c_i == c_k or c_j == c_k:
                continue
            sm = 0
            for i in range(N):
                for j in range(N):
                    mod = (i + j + 2) % 3
                    clr = c[i][j]
                    if mod == 2:
                        sm += d[clr-1][c_i]
                    elif mod == 0:
                        sm += d[clr-1][c_j]
                    else:
                        sm += d[clr-1][c_k]
            ans = min(ans, sm)

print(ans)


### FIXED CODE ###

N, C = map(int, input().split())
d = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(int, input().split())) for _ in range(N)]

mod = [[], [], []]

for i in range(N):
    for j in range(N):
        mod[(i+j)%3].append(c[i][j])

from collections import Counter

c = []
for i in range(3):
    c.append(Counter(mod[i]))

ans = float("inf")
for c_i in range(C):
    for c_j in range(C):
        if c_j == c_i:
            continue
        for c_k in range(C):
            if c_k == c_i or c_k == c_j:
                continue
            li = [c_i, c_j, c_k]
            sm = 0
            for i in range(3):
                counter = c[i]
                for k, v in counter.items():
                    sm += d[k-1][li[i]] * v

            ans = min(ans, sm)

print(ans)