Harryxun/stf_run huggingface dataset:
# maintain overall min 
# iterate over two loops 
# find the absolute distance and before exiting the first maintain overall min
# also check the distance of last and first house
def findDistBetween(i,j):
    return abs(i - j)

def minDistfindDistBetweenLastAndFirstHouse(i,j):
    dist = findDistBetween(i, j)
    return K - dist 

K, N = input().split()
As = input().split()

K = int(K)
N = int(N)

print ("As is")
print (As)
# print (As.split())
A = [0] * len(As)
for i in range(len(As)):
    A[i] = int(As[i])
    
# A = list(map(lambda x: int(x), As))
# print (A)
# overAllMin = float('inf')
# minDist = 0 
# for i in range(N):
#     minDist = 0
#     for j in range(N):
#         # print (i, j)
#         minDist += findDistBetween(A[i], A[j])
#     # find the dist b/w last and first house
#     # minDist2 = minDistfindDistBetweenLastAndFirstHouse(A[0], A[-1])
#     # minDist = min(minDist, minDist2)
#     print ("Min dist", minDist)
#     # print ("min dist2", minDist2)
#     overAllMin = min(overAllMin, minDist)

# print (overAllMin)
overAllMin = float('inf')
Arev = list(reversed(A))
dist1 = 0 
dist2 = 0
prevHouse = -1
for i in range(N):
    #print ("PRev house", prevHouse)
    #print ("Next house", A[i])

    dist1 = max(findDistBetween(A[i], prevHouse), dist1)
    prevHouse = A[i]
    

ma = max(dist1, minDistfindDistBetweenLastAndFirstHouse(A[0], A[-1]))
print (K - ma)
# for i in range(N):
#     count = 0
#     curHouse = A[i]
#     j = i
#     flag0 = 0 
#     flag1 = 0
#     dist1 = 0 
#     dist2 = 0
#     while count < N:
#         if flag0 is 0:
#             dist1 += findDistBetween(curHouse, A[j])
#         curHouse = A[j]
#         j += 1
#         flag0 = 0
#         count += 1

#         if j == N and count < N: 
#             print ("in condition")
#             j = 0
#             dist1 += minDistfindDistBetweenLastAndFirstHouse(A[0], A[-1])
#             flag0 = 1
        
        # count += 1

        # print ("dist1", dist1)

    # count = 0
    # curHouse = A[i]
    # j = i
    # while count < N:
    #     if flag1 is 0:
    #         dist2 += findDistBetween(curHouse, A[j])
    #     curHouse = A[j]
    #     j -= 1
    #     count += 1
    #     flag1 = 0
    #     if j == -1 and count < N: 
    #         j = N - 1 
    #         dist2 += minDistfindDistBetweenLastAndFirstHouse(A[0], A[-1])
    #         flag1 = 1
    #     # count += 1 
# overAllMin = min(dist1, K - findDistBetween(A[0], A[-1]), overAllMin)
# print (dist1,  K - findDistBetween(A[0], A[-1]), overAllMin)
        
# print (overAllMin)    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
     
    
    




### FIXED CODE ###

S = input()

if len(S) >= 6:
    if S[2] is S[3] and S[4] is S[5]:
        print ("Yes")
        exit()
print ("No")
# 159 B

n, a, b = map(int, input().split())
s = ""

while len(s) < n:
    s += a * "b"
    if len(s) >= n:
        break
    s += b * "r"

s = s[:n]
print(s.count("b"))


### FIXED CODE ###

n, a, b = map(int, input().split())
num = 0

x = n // (a + b)
num += (x * a)

y = n % (a + b)

if y <= a:
    num += y
else:
    num += a

print(num)
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# 「番号 n以下 の辺だけを貼ったときの連結成分の大きさが z 以上」を満たす最小のn
# 並列二分探索

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

def find_root(root,x):
    y = root[x]
    if x == y:
        return
    find_root(root,y)
    root[x] = root[y]

def merge(root,size,x,y):
    find_root(root,x)
    find_root(root,y)
    rx = root[x]
    ry = root[y]
    if rx == ry:
        return 0,0
    return (ry,rx) if size[rx] < size[ry] else (rx,ry)

def test(root,size,x,y,z):
    find_root(root,x)
    find_root(root,y)
    rx = root[x]
    ry = root[y]
    if rx == ry:
        return size[rx] >= z
    else:
        return size[rx] + size[ry] >= z

root = list(range(N+1))
size = [1] * (N+1)
merge_1 = [0] * (M+1)
merge_2 = [0] * (M+1)

for t in range(1,M+1):
    a,b = map(int,readline().split())
    x,y = merge(root,size,a,b)
    if x == 0:
        continue
    merge_1[t] = x
    merge_2[t] = y
    root[y] = x
    size[x] += size[y]
    
Q = int(readline())
X = []
Y = []
Z = []
for line in readlines():
    x,y,z = map(int,line.split())
    X.append(x)
    Y.append(y)
    Z.append(z)

left = [0] * Q # 連結成分は z 未満
right = [M] * Q # 連結成分は z 以上
q = tuple([] for _ in range(M+1))# 調べる時刻、番号
done = [False] * (M+1)
for i in range(Q):
    q[M//2].append(i)
rest = Q


while rest:
    root = list(range(N+1))
    size = [1] * (N+1)
    for t in range(1,M+1):
        x = merge_1[t]
        y = merge_2[t]
        if x != 0:
            root[y] = x
            size[x] += size[y]
        if done[t] or not q[t]:
            continue
        done[t] = True
        L = left[q[t][0]]
        R = right[q[t][0]]
        ML = (t+L)//2
        MR = (t+R)//2
        for i in q[t]:
            x = X[i]
            y = Y[i]
            z = Z[i]
            if test(root,size,x,y,z):
                right[i] = t
                mid = ML
            else:
                left[i] = t
                mid = MR
            if left[i] < mid:
                q[mid].append(i)
            else:
                rest -= 1

for x in right:
    print(x)


### FIXED CODE ###

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

if a > 0:
  answer = 'Positive'
elif b >= 0:
  answer = 'Zero'
else:
  # both negative
  x = b - a + 1
  answer = 'Negative' if x & 1 else 'Positive'

print(answer)
N,M = map(int,raw_input().split())

road_list = [[] for i in range(N)]

W = [[-2*(10**9)-1 for j in range(N)] for i in range(N)]
y = [-2*(10**9)-1 for i in range(N)]
y_t = [-2*(10**9)-1 for i in range(N)]
y[0] = 0
y_t[0] = 0

for i in range(N):
    W[i][i]=0

for i in range(M):
    a,b,c=map(int,raw_input().split())
    W[a-1][b-1] = c

flag = False

for i in range(N):
    for j in range(N):
        yj_max = -2*(10**9)-1
        for k in range(N):
            yj_temp = -2*(10**9)-1
            if y[k]!=-2*(10**9)-1 and W[k][j]!=-2*(10**9)-1:
                yj_temp=y[k]+W[k][j]
            if yj_max<yj_temp:
                yj_max = yj_temp
        y_t[j]=yj_max
    if y==y_t:
        flag = True
        break
    y = y_t
    

if flag:
    print y[N-1]
else:
    print 'infty'

### FIXED CODE ###

A,B,C = map(int,raw_input().split())

if C>=A and C<=B:
    print 'Yes'
else:
    print 'No'
x,y=map(int,input().split())
print(max(max(x,y)*2-1,x*2)

### FIXED CODE ###

x,y=map(int,input().split())
if x!=y:
  print(max(x,y)*2-1)
else:
  print(x*2)
N = int(input())
l = list()
al = list()
bl = list()

for n in N:
    a = input()
　 l.append(a)
    al.append(a[:1])
    bl.append(a[-1:])

l_unq = list(set(l))
if len(l) == len(l_unq):
    for i in N-1:
        if al[i+1] != bl[i]:
          print("No")
          break
     print("Yes")
else:
    print("No")

### FIXED CODE ###

N = int(input())
l = list()

for n in range(N):
    a = input()
    l.append(a)

l_uniq = list(set(l))

if len(l) == len(l_uniq):
    for i in range(0, N-1):
        if l[i+1][0] != l[i][-1]:
            print("No")
            break
    else:
        print("Yes")
else:
    print("No")
from collections import deque

n,m=map(int,input().split())
step=list(range(2,n+1))
broken=[]
for i in range(m):
    broken+=[int(input())]
mod=10**9+7
dp=[0]*(n+1)
dp[0]=1
if m==0:
    dp[1]=1
elif not broken[0]==1:
    dp[1]=1
b=deque(broken)
if len(broken) != 0:
    bad_one = b.popleft()
for i in step:
    if i != bad_one:
        dp[i]=(dp[i-1]+dp[i-2])%mod
    elif i == bad_one and len(b) != 0:
        bad_one = b.popleft()
print(dp[n])

### FIXED CODE ###

N, M = list(map(int, input().split()))
A = {i: 0 for i in range(N+1)}
mod = 10 ** 9 + 7
for _ in range(M):
    A[int(input())] = 1
 
dp = [0 for _ in range(N+1)]
dp[0] = 1
 
for i in range(N+1):
    if A.get(i+1) == 0:
        dp[i + 1] += dp[i]
    if A.get(i+2) == 0:
        dp[i + 2] += dp[i]
 
print(dp[N]%mod)
n=int(input())
a=list(map(int,input().split()))
a.sort()
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]:
        if l[j]+l[i]>l[k]:
        ans+=1

print(ans)

### FIXED CODE ###

ss=str(input())
a=int(ss.count("R"))

if ss=="RSR":
  a=1

print(a)
n,k,*a=map(int,open(0).read().split())
z=sorted(a[:n]),sorted(a[n:])[::-1]
o=10**12
g=-1
while o-g>1:
 m,l=o+g>>1,k
 for a,f in zip(z):l-=max(0,a-m//f)
 if l<0:g=m
 else:o=m
print(o)

### FIXED CODE ###

def main():
    n,k,*a=map(int,open(0).read().split())
    a,f=sorted(a[:n])[::-1],sorted(a[n:])
    ok=10**12
    ng=-1
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        l=k
        for b,g in zip(a,f):
            if b*g>mid:
                l-=b-mid//g
        if l<0:ng=mid
        else:ok=mid
    print(ok)
main()
from collections import deque

h, w = map(int, input().split())
field = []
for i in range(h):
    field.append(input())

out = 0
for i in range(h):
    for j in range(w):
        if field[i][j] == '.':
            seen = [[0 for m in range(w)] for n in range(h)]
            seen[i][j] = 1
            q = deque([])
            q.append((i, j, 0))

            while q:
                y, x, cnt = q.popleft()
                # print(y, x, cnt)
                for ny, nx in [(y, x + 1), (y, x - 1), (y + 1, x), (y - 1, x)]:
                    if 0 <= ny < h and 0 <= nx < w and not seen[ny][nx]:
                        if field[ny][nx] == '.':
                            q.append((ny, nx, cnt + 1))
                            seen[y][x] = 1
        out = max(out, cnt)
print(out)


### FIXED CODE ###

from collections import deque

h, w = map(int, input().split())
field = []

for i in range(h):
    field.append(list(input()))

out = 0
for i in range(h):
    for j in range(w):
        if field[i][j] == '.':
            seen = [[0 for m in range(w)] for n in range(h)]
            seen[i][j] = 1
            q = deque([])
            q.append((i, j, 0))
            while q:
                (y, x, cnt) = q.popleft()
                # print(y,x)
                # print(seen)
                for ny, nx in (y, x + 1), (y, x - 1), (y + 1, x), (y - 1, x):
                    if ny < 0 or ny >= h or nx < 0 or nx >= w:
                        pass
                    elif field[ny][nx] == '.' and seen[ny][nx] == 0:
                        q.append((ny, nx, cnt + 1))
                        seen[ny][nx] = 1

            out = max(out, cnt)
print(out)
import random

def is_prime(q,k=50):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n,m=(int(i) for i in input().split(' '))
if m%n>100000:
  for i in range(1,n):
    if m%i==0 and is_prime(i) and is_prime(m//i) and (i==1 or m//i<n):
      print('1')
      exit()
for i in range(n,m+1):
  if i==m:
    print(1)
    break
  if m%i==0:
    print(m//i)
    break
  if m-i-n>0 and m%(m-i-n)==0 and m//(m-i-n)>n:
    print(m-i-n)
    break


### FIXED CODE ###

N = int(input())
if N == 1:
    print('Hello World')
elif N == 2:
    A = int(input(''))
    B = int(input(''))
    print(A + B)
import sys
import math
row = int(sys.argv[1])
column = int(sys.argv[2])

result = 0

if row == 1 or column == 1 :
    result = 1
else:
    result = math.ceil((row * column) / 2)

print(result)

### FIXED CODE ###

import sys
import math
args = sys.stdin.readline().split()
row = int(args[0])
column = int(args[1])

result = 0

if row == 1 or column == 1 :
    result = 1
else:
    result = math.ceil((row * column) / 2)

print(result)
N=int(input())
S=input()
DP=[0]**N
DP[0]=S[1:].count("E")
for i in range(1,N):
  if S[i]=="E":
    DP[i]=DP[i-1]-1+S[:i].count("W")
  else:
    DP[i]=DP[i-1]+S[:i].count("W")
print(min(DP))


### FIXED CODE ###

N=int(input())
S=input()
DP=[0]*N
l=0
for i,x in enumerate(S):
  DP[i]+=l
  if x=="E":
    l+=1
r=0
for i,y in enumerate(S[::-1]):
  DP[N-1-i]+=r
  if y=="W":
    r+=1
print(N-1-max(DP))
N = int(input())
t = 0
if N % 4 == 0 or N % 7 == 0:
  ans = "Yes"
elif N < 4:
  ans = "No"
else:
  for i in range(1, (N//7)+1):
    x = (N - 7*i) / 4
    if int(x) == x:
      ans = "Yes"
    else:
      ans = "No"
print(ans)

### FIXED CODE ###

N = int(input())
t = 0
if N % 4 == 0 or N % 7 == 0:
  ans = "Yes"
else:
  t = 0
  for i in range(1,(N//7)+1):
    x = (N-7*i)/4
    if x == int(x):
      t += 1
    else:
      continue
  if t > 0:
    ans = "Yes"
  else:
    ans = "No"
print(ans)
def cal(A, B):
    if A >= 13:
        return B
    elif 6 <= A and A <= 12:
        return B/2
    elif 5 <= A:
        return 0

if __name__ == "__main__":
    A = int(input())
    B = int(input())
    print(cal(A, B))

### FIXED CODE ###

def main():
    i = list(map(int, input().split()))
    a = i[0]
    b = i[1]

    #if isinstance(a, int) == False or isinstance(b, int) == False or a < 0 or 100 < a or b < 2 or 1000 < b or b % 2 != 0:
    #    return

    if 13 <= a and a <= 100:
        print(b)
    elif 6 <= a and a <= 12:
        print(b//2)
    elif 0 <= a and a <= 5:
        print(0)

if __name__ == "__main__":
    main()
n, k = map(int, input().split())
lst = list(map(int, input().split()))
res = []
for i in range(k):
  throwaways = i
  take = k - throwaways
  # throwaways cannot be larger than take
  if throwaways > take:
    break
  for j in range(take+1):
    right = lst[:j]
    if len(right) < take:
      l = take - len(right)
      left = lst[l*-1:]
    else:
      left = []
    m_lst = sorted(right + left)
    for t in range(throwaways):
      del m_lst[0]
    res.append(m_lst)
max_num = max([sum(e) for e in res])
if max_num <= 0:
  print(0)
else:
  print(max_num)

### FIXED CODE ###

n, k = map(int, input().split())
lst = list(map(int, input().split()))
res = []
for i in range(min(k, len(lst))):
  throwaways = i
  take = min(k - throwaways, len(lst))
  # throwaways cannot be larger than take
  if throwaways > take:
    break
  for j in range(take+1):
    right = lst[:j]
    if len(right) < take:
      l = take - len(right)
      left = lst[l*-1:]
    else:
      left = []
    m_lst = sorted(right + left)
    for t in range(throwaways):
      # throw away if it's value is negative
      if m_lst[0] < 0:
        del m_lst[0]
    res.append(m_lst)
max_num = max([sum(e) for e in res])
if max_num <= 0:
  print(0)
else:
  print(max_num)
a = input()
print(int(a * a))

### FIXED CODE ###

a = int(input())
print(a**2)
import numpy as np
N=int(input())
A=[[]]
X=[[]]
Y=[[]]
for i in range(1,N+1):
    a=int(input())
    A.append(a)
    x=[[]]
    y=[[]]
    for j in range(a):
        b=list(map(int,input().split()))
        x.append(b[0])
        y.append(b[1])
    X.append(x)
    Y.append(y)
ans=0
for bits in range(1 << N):
    #print(bin(bits))
    ok=True
    for i in range(1,N+1):
        if not (bits & (1<<i-1)):
            continue
        for j in range(1,A[i]+1):
            if(((bits >> (X[i][j]-1)) & 1) ^ Y[i][j]):
                ok = False
        
    if ok:
#        print(ok,bin(bits))
        ans = max(ans, counter(bits))
print(ans)

### FIXED CODE ###

def counter(x):
    if x==0:
        return 0
    return counter(x >> 1) + (x & 1)
N=int(input())
A=[[]]
X=[[]]
Y=[[]]
for i in range(1,N+1):
    a=int(input())
    A.append(a)
    x=[[]]
    y=[[]]
    for j in range(a):
        b=list(map(int,input().split()))
        x.append(b[0])
        y.append(b[1])
    X.append(x)
    Y.append(y)
ans=0
for bits in range(1 << N):
    #print(bin(bits))
    ok=True
    for i in range(1,N+1):
        if not (bits & (1<<i-1)):
            continue
        for j in range(1,A[i]+1):
            if(((bits >> (X[i][j]-1)) & 1) ^ Y[i][j]):
                ok = False
        
    if ok:
#        print(ok,bin(bits))
        ans = max(ans, counter(bits))
print(ans)
N,M = list(map(int,input().split()))
p = list(map(int,input().split()))
p = [i-1 for i in p]
rem = [True for i in range(N)]
xy = [[] for i in range(N)]
for i in range(M):
    x,y = list(map(int,input().split()))
    x -= 1
    y -= 1
    xy[x].append((y,p.index(y)))
    xy[y].append((x,p.index(x)))
    rem[x] = False
    rem[y] = False
count = 0
for i in range(N):
    if rem[i] and p[i] == i:
        count += 1
alr = rem.copy()
for i in range(N):
    if (not alr[i]) and (xy[i]):
        alr[i] = True
        stack = [j for j in xy[i]]
        indlist = [p.index(i)]
        numlist = [i]
        while stack:
            num,ind = stack.pop()
            alr[num] = True
            numlist.append(num)
            indlist.append(ind)
            for j in xy[num]:
                if not alr[j[0]]:
                    alr[j[0]] = True
                    stack.append(j)
        for num in numlist:
            if num in indlist:
                count += 1
print(count)
                
    
        

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
N,M = list(map(int,input().split()))
p = [i-1 for i in map(int,input().split())]
alr = [False for i in range(N)]
xy = [[] for i in range(N)]
for i in range(M):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    xy[x].append(y)
    xy[y].append(x)
count = 0

for i in range(N):
    if (not alr[i]) and (xy[i]):
        alr[i] = True
        stack = [i]
        numlist = set()
        numlist.add(i)
        while stack:
            j = stack.pop()
            for k in xy[j]:
                if not alr[k]:
                    alr[k] = True
                    stack.append(k)
                    numlist.add(k)
        indlist = set([p[i] for i in numlist])
        count += len(numlist & indlist)
    else:
        if (not alr[i]) and p[i] == i:
            count += 1
print(count)
# ABC169A

x = map(int, input().split())
print(x.index(0)+1)


### FIXED CODE ###

# ABC169A

x = list(map(int, input().split()))
print(x.index(0)+1)
n,q = map(int, input().split())
s = input()
lr = list(map(str, [input() for i in range(q)]))

ac = [0]*n


for i in range(1,n):
	if s[i] =='C':
		if s[i-1] == 'A':
			ac[i-1] = 1

for i in range(q):
	answer = sum(ac[int(lr[i][0])-1:int(lr[i][2])])
	if answer >= 1:
		if ac[int(lr[i][2])-1] == 1:
			answer -= 1
	print(answer)


### FIXED CODE ###

#累積和　なるほど！

n,q = map(int, input().split())
s = input()
lr = list(map(str, [input() for i in range(q)]))

ac = [0]*n
#012345678
# ACACTACG
# 01122233

for i in range(1,n):
	if s[i-1:i+1] =='AC':
		ac[i] = ac[i-1] + 1
	else:
		ac[i] = ac[i-1]

for i in range(q):
	l,r = map(int, lr[i].split())
	answer = ac[r-1]-ac[l-1] 

	print(answer)
N=int(input())
ST=[list(map(int,input().split())) for i in range(N)]
X=input()
ans=-1
for s,t in ST:
  if s !=X and ans==-1:
    continue
  else:
    if ans==-1:
      ans=0
    else:
      ans+=int(t)
print(ans)


### FIXED CODE ###


N=int(input())
ST=[list(input().split()) for i in range(N)]
X=input()
ans=-1
for s,t in ST:
  if s !=X and ans==-1:
    continue
  else:
    if ans==-1:
      ans=0
    else:
      ans+=int(t)
print(ans)
#!/usr/bin/env python3
#ABC140 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
s = list(input())
l = []
cnt = 1
for i in range(1,n):
    if s[i-1] != s[i]:
        l.append((cnt,i-1))
        cnt = 0
    cnt += 1
l.append((cnt,i))
m = len(l)
if m//2 <= k:
    print(n-1)
    quit()
h = []
for i in range(m):
    if i == 0:
        heappush(h,(-(l[i][0]+l[i+1][0]),l[i][0],l[i][1]))
    elif i == m-1:
        heappush(h,(-(l[i][0] + l[i-1][0]),l[i][0],l[i][1]))
    else:
        heappush(h,(-(l[i][0] + l[i-1][0] + l[i+1][0]),l[i][0],l[i][1]))
for _ in range(min(k,len(h))):
    l,i,j = heappop(h)
    if s[j] ==  'R':
        s[j-i+1:j+1] = 'L'*i
    else:
        s[j-i+1:j+1] = 'R'*i
ans = 0
for i in range(n):
    if s[i] == 'L':
        if i > 0:
            if s[i-1] == 'L':
                ans += 1
    else:
        if i < n-1:
            if s[i+1] == 'R':
                ans += 1
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
#ABC140 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
s = input()
x,y = 0,0
for i in range(1,n):
    if s[i] == s[i-1]:
        x += 1
    else:
        y += 1
print(x + min(y,2*k))
n = int(input())
if n == 1:
    print('Hello World')
else:
    A,B = map(int,input().split())
    print(A+B)

### FIXED CODE ###

n = int(input())
if n == 1:
    print('Hello World')
else:
    A = int(input())
    B = int(input())
    print(A+B)
import math

def f(a, n):
    res = math.inf
    for b in range(-n-1, n+1):
        s = (b+i for i in range(1, n+1))
        sadness = sum(abs(ai - xi) for (ai, xi) in zip(a, s))
        res = min(res, sadness)
    
    return res
    
n = int(input())
a = [int(i) for i in input().split()]
print(f(a, n))


### FIXED CODE ###

import statistics

def f(a, n):
    a2 = [ai - (i+1) for (i,ai) in enumerate(a)]
    b = int(statistics.median(a2))
    
    sadness = sum(abs(ai - b) for ai in a2)
    
    b += 1
    sadness2 = sum(abs(ai - b) for ai in a2)

    
    return min(sadness, sadness2)
    
n = int(input())
a = [int(i) for i in input().split()]
print(f(a, n))
#https://atcoder.jp/contests/dp/tasks/dp_d
N,W = map(int,input().split())
Goods_List=[]
for i in range(N):
    Goods_List.append(list(map(int,input().split())))

Sum_Weight = sum(map(lambda x:x[0],Goods_List))
dp = [[-1] * Sum_Weight for i in range(N)]

for i in range(N):
    Current_Weight = Goods_List[i][0]
    Current_Value  = Goods_List[i][1]
    dp[i][0] = 0
    if i == 0:
        dp[i][Current_Weight] = Current_Value
    else:
        Search_List = [j for j, x in enumerate(dp[i-1]) if x > -1]
        Comb_List = [0,Current_Weight]
        for k in Search_List:
            for l in Comb_List:
                if k + l > W:
                    break
                elif l == 0:
                    dp[i][k+l] = dp[i-1][k+l]
                else:
                    dp[i][k+l] = max(dp[i-1][k+l],dp[i-1][k]+Current_Value)
                    
print(max(dp[N-1]))

### FIXED CODE ###

#https://atcoder.jp/contests/dp/tasks/dp_d
N,W = map(int,input().split())
Goods_List=[]
for i in range(N):
    Goods_List.append(list(map(int,input().split())))

Sum_Weight = sum(map(lambda x:x[0],Goods_List))
dp = [[-1] * (W + 1) for i in range(N)]

for i in range(N):
    Current_Weight = Goods_List[i][0]
    Current_Value  = Goods_List[i][1]
    dp[i][0] = 0
    if (i == 0) & (Current_Weight <= W) :
        dp[i][Current_Weight] = Current_Value
    elif i > 0:
        Last_Search_List = [j for j, x in enumerate(dp[i-1]) if x > -1]
        Current_Search_List = list(map(lambda x:x+Current_Weight,Last_Search_List))
        ##まずは前回値を入れる
        for l in range(len(Last_Search_List)):
            Last_Search_Weight =  Last_Search_List[l] 
            dp[i][Last_Search_Weight] = dp[i-1][Last_Search_Weight]
        ##今回値と比べる
        for k in range(len(Current_Search_List)):
            Last_Search_Weight =  Last_Search_List[k] 
            Current_Search_Weight = Current_Search_List[k]
            if Current_Search_Weight > W:
                break
            else:
                dp[i][Current_Search_Weight] = max((dp[i-1][Last_Search_Weight] + Current_Value),
                                                   dp[i-1][Current_Search_Weight])


print(max(dp[N-1]))
a,b=map(int,input().split())
if a!=3 and b!=3:
  print('3')
elif a!=2 and b!=2:
  print('2')
else:
  print('1')

### FIXED CODE ###

a=int(input())
b=int(input())
if a!=3 and b!=3:
  print(3)
elif a!=2 and b!=2:
  print(2)
else:
  print(1)