Harryxun/stf_run huggingface dataset:
for i in range(m):
    a, b, c = map(int, input().split())
    edges[a-1].append([b-1, c])
    edges[b-1].append([a-1, c])


def dijkstra(num_of_node, edge, start, limit):
    distance = [float('INF')] * num_of_node
    reachable = []
    distance[start] = 0
    todo = []
    heapq.heapify(todo)
    heapq.heappush(todo, [0, start])

    while todo:
        d, node = heapq.heappop(todo)
        if d > limit:
            break
        reachable.append(node)
        for new_node, cost in edge[node]:
            if distance[new_node] > d + cost:
                distance[new_node] = d + cost
                heapq.heappush(todo, [d+cost, new_node])

            else:
                continue
    return reachable


L_edges = [[]*n for _ in range(n)]

for i in range(n):
    L_edges[i] = dijkstra(n, edges, i, full)

dist = [[float('INF')] * n for _ in range(n)]

for start in range(n):
    dist[start][start] = 0
    todo = deque([])
    todo.append([-1, start])

    while todo:
        d, node = todo.popleft()

        for new_node in L_edges[node]:
            if dist[start][new_node] > d + 1:
                dist[start][new_node] = d + 1
                todo.append([d+1, new_node])

            else:
                continue

Q = int(input())
for i in range(Q):
    s, t = map(int, input().split())
    ans = dist[s-1][t-1]
    if ans == float('INF'):
        ans = -1
    print(ans)


### FIXED CODE ###

from scipy.sparse.csgraph import csgraph_from_dense
from scipy.sparse.csgraph import floyd_warshall

n, m, energy = map(int, input().split())
edges = [[float('INF')]*n for _ in range(n)]

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

G = csgraph_from_dense(edges, null_value=float('INF'))
dist = floyd_warshall(G)

L_edges = [[float('INF')]*n for _ in range(n)]
for i in range(n-1):
    for j in range(i, n):
        if dist[i][j] <= energy:
            L_edges[i][j] = 1
            L_edges[j][i] = 1

G = csgraph_from_dense(L_edges, null_value=float('INF'))
answers = floyd_warshall(G)

Q = int(input())
for i in range(Q):
    s, t = map(int, input().split())
    ans = answers[s-1][t-1] - 1
    if ans == float('INF'):
        ans = -1
    print(int(ans))
from itertools import accumulate

N, K = map(int,input().split())
S = input()

nums = []
tmp = "1" #はじめに0が入ったら、0からスタートというのがわかる。
count = 0
for s in S:
    if tmp == s:
        count += 1
    else:
        nums.append(count)
        count = 1
        tmp = s
nums.append(count)

# print(nums)
# 累積和表示にする(listって足し算できるのね)
# これによって、各文字最初の値が明らかになる
acc = [0]+list(accumulate(nums))
# print(acc)
n = len(nums)
w = min(2*K + 1)

ans = 0
for i in range(0,n-w+1,2): #2個飛ばし
    ans = max(ans,acc[i+w]-acc[i])
print(ans)

### FIXED CODE ###

from itertools import accumulate

N, K = map(int,input().split())
S = input()

nums = []
tmp = "1" #はじめに0が入ったら、0からスタートというのがわかる。
count = 0
for s in S:
    if tmp == s:
        count += 1
    else:
        nums.append(count)
        count = 1
        tmp = s
nums.append(count)
if tmp == "0":
    nums.append(0) #エッジの条件

# print(nums)
# 累積和表示にする(listって足し算できるのね)
# これによって、各文字最初の値が明らかになる
acc = [0]+list(accumulate(nums))
# print(acc)
n = len(nums)
w = 2*K + 1

if len(nums) <= w:
    print(N)
else:
    ans = 0
    for i in range(0,n-w+1,2): #2個飛ばし
        ans = max(ans,acc[i+w]-acc[i])

    print(ans)
import numpy as np
import sys

L, N = map(int, input().split())
X = np.array([int(sys.stdin.readline()) for _ in range(N)])
Y1 = np.concatenate(([X[0]], X[1:] - X[:-1], [L - X[-1]]))

X2 = X[::-1]
Y2 = Y1[::-1]


def func(n):
    return np.concatenate((np.full(n + 1, N - n, dtype=np.int), np.arange(N - n - 2, -1, -2), np.arange(N - n - 1, -1, -2)[::-1]))


if N < 10000:
    ans = 0
    for n in range((N + 1) // 2):
        a = func(n)
        len1 = np.dot(a, Y1)
        len2 = np.dot(a, Y2)
        ans = max(ans, len1, len2)

    print(ans)
else:
    ans = 0
    cn = (N + 1) // 200
    len1 = [0] * cn
    len2 = [0] * cn
    can1 = [0] * cn
    can2 = [0] * cn
    for n in range(0, (N + 1) // 2, 100):
        a = func(n)
        i = n // 100
        len1[i] = np.dot(a, Y1)
        len2[i] = np.dot(a, Y2)
        ans = max(ans, len1[i], len2[i])

    print(ans)

### FIXED CODE ###

import numpy as np
import sys

L, N = map(int, input().split())
X = np.array([int(sys.stdin.readline()) for _ in range(N)])
X2 = L - X[::-1]
Y1 = np.concatenate(([X[0]], X[1:] - X[:-1], [L - X[-1]]))
Y2 = Y1[::-1]
Z = np.concatenate((np.arange(N, -1, -2), np.arange(N - 1, -1, -2)[::-1]))


def myfunc(n, x):
    return x[n + (N - n + 1)//2 - 1] - 2 * x[n - 1] - (L - x[N - (N - n + 1)//2])


len1 = np.dot(Z, Y1)
len2 = np.dot(Z, Y2)
x1 = X.tolist()
x2 = X2.tolist()
ans = max(len1, len2)
for n in range(1, (N + 1) // 2):
    len1 += myfunc(n, x1)
    len2 += myfunc(n, x2)
    ans = max(ans, len1, len2)

print(ans)
s = input()
a = 0
for i in s:
  a += i
print(2 * min(a, len(s)-a))

### FIXED CODE ###

S = input()
print(2*min(S.count("1"),S.count("0")))
N, K = map(int, input().split())
X = list(map(int, input().split()))

x_minus = [a for a in X if a < 0]
x_plus = [a for a in X if a >= 0]

ans = float("inf")
for i in range(K+1):
    if i == 0:
        if len(x_plus) >= K:
            dis = x_plus[K - 1]
            ans = min(ans, dis)
        else:
            continue
    if i != 0:
        if len(x_minus) > i and len(x_plus) >= K - i:
            if i != K-1:
                dis = 2 * abs(x_minus[-i]) + x_plus[K - i - 1]
                ans = min(ans, dis)
                dis = 2 * x_plus[K - i - 1] + abs(x_minus[-i])
                ans = min(ans, dis)
            elif i == K - 1:
                dis = 2 * abs(x_minus[-i]) + x_plus[K - i - 1]
                ans = min(ans, dis)
        else:
            continue
    if i == K:
        if len(x_minus) >= K:
            dis = abs(x_minus[-K])
            ans = min(ans, dis)


print(ans)


### FIXED CODE ###

N, K = map(int, input().split())
X = list(map(int, input().split()))

x_minus = [a for a in X if a < 0]
x_plus = [a for a in X if a >= 0]

ans = float("inf")
for i in range(K+1):
    if i == 0:
        if len(x_plus) >= K:
            dis = x_plus[K - 1]
            ans = min(ans, dis)
        else:
            continue
    elif 1 <= i <= K - 1:
        if len(x_minus) >= i and len(x_plus) >= K - i:
            dis = 2 * abs(x_minus[-i]) + x_plus[K - i - 1]
            ans = min(ans, dis)
            dis = 2 * x_plus[K - i - 1] + abs(x_minus[-i])
            ans = min(ans, dis)
        else:
            continue
    elif i == K:
        if len(x_minus) >= K:
            dis = abs(x_minus[-K])
            ans = min(ans, dis)


print(ans)
s = input()
t = input()
dic = defaultdict(set)
for x, y in zip(s, t):
  if x != y:
    dic[x].add(y)
    dic[y].add(x)
f = True
for key in dic:
  if len(dic[key]) > 1:
    print("No")
  	f = False
if f:
  print("Yes")
    

### FIXED CODE ###

from collections import defaultdict
s = input()
t = input()
dic = defaultdict(lambda : None)
revdic = defaultdict(lambda : None)
for x, y in zip(s, t):
    if dic[x] == None and revdic[y] == None:
        dic[x] = y
        revdic[y] = x
    elif dic[x] != y or revdic[y] != x:
        print('No')
        quit()
print('Yes')
#coding: utf-8
from collections import deque

H, W = (int(x) for x in input().split())
A = []

posOdd = deque() 
i = 0
j = 0

while (i, j) != H-1, W-1:
    if i

for i in range(H):
    row = [int(x) for x in input().split()]
    A.append(row)



def move(src, dst):
    ret = []
    while src[0] != dst[0]:
        if src[0] > dst[0]:
            di = -1
        else:
            di = 1
        ret.append((src[0], src[1], src[0]+di, src[1]))
        src[0] += di 
    return ret

    while src[1] != dst[1]:
        if src[1] > dst[1]:
            dj = -1
        else:
            dj = 1
        ret.append((src[0], src[1], src[0], src[1]+dj))
        src[1] += dj 

moves = []
while len(posOdd) > 1:
    dst = posOdd.popleft()
    src = posOdd.popleft()
    moves += move(src, dst)

print(len(moves))
for m in moves:
    print(" ".join((str(i+1) for i in m)))


### FIXED CODE ###

#coding: utf-8
from collections import deque

H, W = (int(x) for x in input().split())
A = []

curMove = []
moves = []
hasOdd = False
pi = -1
pj = -1
for i in range(H):
    row = [int(x) for x in input().split()]
    if i % 2 == 0:
        start, end, diff = 0, W, 1
    else:
        start, end, diff = W-1, 0-1, -1

    for j in range(start, end, diff):
        if row[j] % 2 == 1:
            if hasOdd:
                curMove.append((pi,pj, i, j))
                moves += curMove
                curMove = []
                hasOdd = False
            else:
                hasOdd = True
        else:
            if hasOdd:
                curMove.append((pi,pj, i, j))
        pi = i
        pj = j

print(len(moves))
for m in moves:
    print(" ".join((str(i+1) for i in m)))
N=int(input())
ans=0
for i in range(N):
	if i%3!==0 and i%5==0:
      ans+=i
print(ans)

### FIXED CODE ###

N = int(input())
ans = 0
for i in range(N+1):
  if i % 3 == 0 or i % 5 == 0:
    pass
  else:
    ans += i
print(ans)
import numpy as np
N=int(input())
A=[int(_) for _ in input().split()]
X=np.eye(N)
for i in range(N-1):
    X[i+1][i]=1
X[0][N-1]=1
ans=np.dot(A,np.linalg.inv(X))*2
print(*ans.astype(int))

### FIXED CODE ###

N=int(input())
A=[int(_) for _ in input().split()]
ans=[0]*N
ans[0]=sum(A)//2-sum(A[1::2])
for i in range(N-1):
    ans[i+1]=A[i]-ans[i]
print(' '.join(str(2*a) for a in ans))
N, Y = map(int, input().split())

if Y / 1000 == N:
  print('0 0',N)

man_max = Y // 10000
gosen_max = Y // 5000

is_exist = False

for i_m in range(man_max+1):
  for i_g in range(gosen_max+1):
    if 99000*i_m + 4000*i_g == Y - 1000*N:
      print(i_m, i_g, int(Y / 1000 - 10*i_m - 5*i_g))
      is_exist = True
      break
      
if not is_exist:

### FIXED CODE ###

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

man_max = Y // 10000
gosen_max = Y // 5000

for x in range(man_max+1):
  for y in range(gosen_max+1):
    z = N - x - y
    if 0 <= z <= 2000 and 10000*x + 5000*y + 1000*z == Y:
      print(x, y, z)
      exit()
      
print(-1, -1, -1)
if __name__ == "__main__":
    H, W = map(int, input().split())
    s = []
    for i in range(H):
        s.append(input())
    
    """
    # black
    . white
    """
    
    black = "#"
    white = "."
    
    ans = "Yes"
    break_flag = False
    for i in range(H):
        for j in range(W):
            if s[i][j] == black:
                above = False
                under = False
                left = False
                right = False
                
                if 0 < i:
                    above = (s[i - 1][j] == black)
                if i < W - 1:
                    under = (s[i + 1][j] == black)
                if 0 < j:
                    left = (s[i][j - 1] == black)
                if j < W - 1:
                    right = (s[i][j + 1] == black)
                
                if not (above or under or left or right):
                    break_flag = True
                    ans = "No"
                    #print(i, j)
                    #print(above, under, left, right)
            
            if break_flag:
                break
            
        if break_flag:
            break
    
    print(ans)

### FIXED CODE ###

if __name__ == "__main__":
    H, W = map(int, input().split())
    s = []
    for i in range(H):
        s.append(input())
    
    """
    # black
    . white
    """
    
    black = "#"
    white = "."
    
    ans = "Yes"
    break_flag = False
    for i in range(H):
        for j in range(W):
            if s[i][j] == black:
                above = False
                under = False
                left = False
                right = False
                
                if 0 < i:
                    above = (s[i - 1][j] == black)
                if i < H - 1:
                    under = (s[i + 1][j] == black)
                if 0 < j:
                    left = (s[i][j - 1] == black)
                if j < W - 1:
                    right = (s[i][j + 1] == black)
                
                if not (above or under or left or right):
                    break_flag = True
                    ans = "No"
                    #print(i, j)
                    #print(above, under, left, right)
            
            if break_flag:
                break
            
        if break_flag:
            break
    
    print(ans)
H,N = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
dp = [0]*(H+1)
for i in range(1,H + 1):
  dp[i] = min(dp[i-a]+b for a,b in AB)
print(dp[H])

### FIXED CODE ###

H,N = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
maxA = max(a for a,b in AB)
dp = [0]*(H+maxA)
for i in range(1,H + maxA):
  dp[i] = min(dp[i-a]+b for a,b in AB)
print(dp[H])
n,m=map(int,input().split())
mm=[]
for i in range(m):
    s=int(input())
    mm.append(s)
a=n-sum(mm)
if a>=0:
    print(a)
else: print(-1)

### FIXED CODE ###

n,m=map(int,input().split())
mm=list(map(int,input().split()))
a=n-sum(mm)
if a>=0:
    print(a)
else: print(-1)
S = input()
T = input()
C = []
for i in range(len(S) - len(T)):
  s = S[i:len(T)+i]
  c = 0
  for j in range(len(T)):
    if s[j] == T[j]:
      c += 1
  C.append(c) 
print(len(T)-max(C))
   
    

### FIXED CODE ###

S = input()
T = input()
C = []
if len(S) == len(T):
  c = 0
  for j in range(len(T)):
      if S[j] == T[j]:
        c += 1
  C.append(c)
else:
  for i in range(len(S) - len(T)+1):
    s = S[i:len(T)+i]
    c = 0
    for j in range(len(T)):
      if s[j] == T[j]:
        c += 1
    C.append(c)
print(len(T)-max(C))
n=int(input());print(1/2 if n%2=0 else (n//2+1)/n)

### FIXED CODE ###

n=int(input());print(1/2 if n%2==0 else (n//2+1)/n)
N=int(input())
A=list(map(int,input().split()))

cnt=0

while all(a % 2 == 0 for a in A)
	A = [a /2 for a in A]
	cnt += 1

print(cnt)

### FIXED CODE ###

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

cnt=0

while all(a % 2 == 0 for a in A):
	A = [a /2 for a in A]
	cnt += 1

print(cnt)
A, B, H, M = map(int, input().split())


h = (H / 12 + (M / 60 / 12)) * 2 * math.pi
m = M / 60 * 2 * math.pi

ax = A * math.cos(h)
ay = A * math.sin(h)

bx = B * math.cos(m)
by = B * math.sin(m)

#print(h, m, ax, ay, bx, by)

ans = ((ax-bx)**2 + (ay-by)**2 )**(1/2)

print(ans)

### FIXED CODE ###

import math
            
A, B, H, M = map(int, input().split())

"""
h = (H / 12 + (M / 60 / 12)) * 2 * math.pi
m = M / 60 * 2 * math.pi

ax = A * math.cos(h)
ay = A * math.sin(h)

bx = B * math.cos(m)
by = B * math.sin(m)

#print(h, m, ax, ay, bx, by)

ans = ((ax-bx)**2 + (ay-by)**2 )**(1/2)

print(ans)
"""

ang = ((H / 12 + (M / 60 / 12)) - (M / 60)) * 360

#print(ang)

C = ang * math.pi / 180 if ang < 180 else (360 - ang) * math.pi / 180

#print(C / math.pi)

c2 = A**2 + B**2 - 2 * A * B * math.cos(C)

print((c2)**(1/2))
length = int(input())
string = input()
count=0
for i in range(0,length):
    if ("A" == string[i]) and ("B" == string[i+1]) and ("C" == string[i+2]):
        count+=1
        i+=3
        if i>length-3:
            break
print(count)

### FIXED CODE ###

length = int(input())
string = input()
print(string.count("ABC"))
from collections import Counter


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    n = read_int()
    A = read_ints()
    MAX = max(A)+1 # 10**6+1
    count = [Counter() for i in range(MAX)]
    modulo = 10**9+7
    # disassemble all numbers up to 10**6
    for number in range(2, MAX):
        if len(count[number]) > 0: # not prime
            continue
        for step in range(number, MAX, number):
            temp = number
            while step%temp == 0:
                count[step][number] += 1
                temp *= number
    max_counter = Counter()
    for a in A:
        for k, v in count[a].items():
            max_counter[k] = max(max_counter[k], v)
    answer = 0
    for a in A:
        B = 1
        for k, v in max_counter.items():
            B = (B*k**(v-count[a][k]))%modulo
        answer = (answer+B)%modulo
    return answer


if __name__ == '__main__':
    print(solve())


### FIXED CODE ###

import math
from typing import List, Counter, Tuple
from collections import Counter
from itertools import permutations, zip_longest, groupby


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))

modulo = 10**9+7


def merge(A, start, end, divisors):
    if start == end:
        return Counter(divisors[A[start]])
    mid = start+(end-start)//2
    left = merge(A, start, mid, divisors)
    right = merge(A, mid+1, end, divisors)
    for r in right:
        left[r] = max(left[r], right[r])
    return left

def solve() -> int:
    N = read_int()
    A = read_ints()
    M = 10**6+1
    divisors: List[List[int]] = [[] for _ in range(M)]
    for i in range(2, M):
        if len(divisors[i]) == 0:
            for j in range(i, M, i):
                temp = j
                while temp%i == 0:
                    divisors[j].append(i)
                    temp //= i
    lcd_counter = merge(A, 0, N-1, divisors)
    lcd = 1
    for k in lcd_counter:
        lcd = (lcd*pow(k, lcd_counter[k], modulo))%modulo
    answer = 0
    for a in A:
        answer = (answer+(lcd*pow(a, modulo-2, modulo))%modulo)%modulo
    return answer


if __name__ == '__main__':
    print(solve())
n =input()
a = n / 1.08
if a-int(a) == 0.00:
      x = int(a)
else:
      x = int(a) + 1
v = int(x * 1.08)
if v == n:
  print(x)
else:
  print(":(")


### FIXED CODE ###

n=int(input())
a = n / 1.08
if a-int(a) == 0.00:
      x = int(a)
else:
      x = int(a) + 1
v = int(x * 1.08)
if v == n:
  print(x)
else:
  print(":(")
N, A, B = map(int, input().split())

n = int(N / (A + B))

if(N < A+B):
    print((n+1)*A)
elif(N == A+B):
    print(A)
else:
    print(N -B*n)

### FIXED CODE ###

S = input()

if(S == "AAA"):
    print('No')
elif(S == "BBB"):
    print('No')
else:
    print('Yes')
import numpy as np
import sys

def intinput():
    return map(int,sys.stdin.readline().split())

n,m=intinput()
a = list(intinput())
x = np.zeros((2,m),int)
for i in range(m):
    x[0,i],x[1,i]=intinput()
y = np.empty(n+np.sum(x[0]),dtype="int64")
y[0:n]=a
x = x.T
k = 0
for i in x:
    y[n+k:n+k+i[0]]=i[1]
    k+=i[0]
y=np.sort(y)[::-1]
print(np.sum(y[0:n]))

### FIXED CODE ###

import sys

def intinput(): return map(int,sys.stdin.readline().split())

n,m=intinput()
a = list(intinput())
a = [(a[x],1) for x in range(n)]
for i in range(m):
    b,c=intinput()
    a.append((c,b))
a.sort(reverse=1)
res,cnt=0,n
for (x,y) in a:
    k = min(cnt,y)
    res += k*x
    cnt -= k
print(res)
def primes(n):
    prime = [1]*(n+1)
    p=2
    while p*p <= n+1:
        if(prime[p]==True):
            i=p*p
            while i <= n+1:
                prime[i]=0
                i+=p
        p+=1
    return prime
    
def g(a,b):
    if(b==0):
        return a
    else:
        return g(b,a%b)
        
n,m = map(int,input().split())
if(n<=m):
    a=n
    b=m
else:
    a=m
    b=n
if a==1:
    print(a)
else:
    gcd = g(b,a)
    l =[]
    for i in range(1,gcd):
        if(n%i==0 and m%i==0):
            l.append(i)
    p = primes(gcd)
    count=0
    for i in range(len(l)):
        if(p[l[i]]==1):
            count+=1
    print(count)        


### FIXED CODE ###

def primes(n):
    i = 2
    prime = []
    while i**2<= n:
        if n % i:
            i += 1
        else:
            n =n//i
            prime.append(i)
    if n > 1:
        prime.append(n)
    return prime
a,b=map(int,input().split())
pa=set(primes(a))
pb=set(primes(b))
inte=pa.intersection(pb)
print(len(inte)+1)
n = int(input())
h = list(map(int, input().split()))

for i in range(2,n+1):
    if h[n-i] < h[n-i+1]:
        ans = i - 1
        break
print(ans)

### FIXED CODE ###

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

ans = 0
mx = h[0]
for i in range(n):
    if h[i] >= mx:
        ans = ans + 1
        mx = h[i]
print(ans)
N = int(input())
A = list(map(int, input().split(" ")))
A.sort()

n_pos = len([a for a in A if a > 0])
operations = []
if n_pos <= (N + 1) // 2:
    pos = [a for a in A if a > 0]
    neg = [a for a in A if a <= 0]
    tmp = pos[0]
    for i in range(n_pos-1):
        operations.append((neg[i], tmp))
        tmp = neg[i] - tmp
        operations.append((pos[i+1], tmp))
        tmp = pos[i+1] - tmp
        
    for i in range(n_pos-1, len(neg)):
        operations.append((tmp, neg[i]))
        tmp = tmp - neg[i]
else:
    neg = A[:N//2]
    pos = A[N//2:]
    tmp = pos[0]
    for i in range(N//2):
        operations.append((neg[i], tmp))
        tmp = neg[i] - tmp
        operations.append((pos[i+1], tmp))
        tmp = pos[i+1] - tmp

print(tmp)
for o in operations:
    print("{} {}".format(o[0], o[1]))

### FIXED CODE ###

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

n_pos = len([a for a in A if a > 0])
operations = []
if n_pos == 0:
    pos = [A[-1]]
    neg = A[:-1]
elif n_pos == N:
    pos = A[1:]
    neg = A[:1]
else:
    pos = [a for a in A if a > 0]
    neg = [a for a in A if a <= 0]
if len(pos) >= 2:
    tmp = neg[0]
    for i in range(len(pos)-1):
        operations.append((tmp, pos[i]))
        tmp = tmp - pos[i]
    operations.append((pos[-1], tmp))
    tmp = pos[-1] - tmp
    for i in range(1, len(neg)):
        operations.append((tmp, neg[i]))
        tmp = tmp - neg[i]
else:
    tmp = pos[0]
    for i in range(len(neg)):
        operations.append((tmp, neg[i]))
        tmp = tmp - neg[i]
print(tmp)
for o in operations:
    print("{} {}".format(o[0], o[1]))
N=int(input())
A=list(map(int,input().split()))
B=[A[i]-i for i in range(N)]
C=median(B)
print(sum([b-C for b in B]))

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
B=sorted([A[i]-i for i in range(N)])
if N%2==0:
	C=int((B[int(N/2)]+B[int(N/2-1)])/2)
else:
	C=B[int((N-1)/2)]
print(sum([abs(b-C) for b in B]))
a = input()
b = input()
print((int(a) * int(b)),8(int(a) * 2) + (int(b) * 2)))

### FIXED CODE ###

a ,b = input().split(' ')
print(int(a) * int(b),(int(a) * 2) + (int(b) * 2))