Harryxun/stf_run huggingface dataset:
def main():
    N = input()
    a = map(int, raw_input().split())
    print ' '.join(map(str,a))
    for i in xrange(1,len(a)-1):
        v = a[i]
        j = i - 1
        while j >= 0 && a[j] > v:
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v
        print ' '.join(map(str,a))
    return 0

main()

### FIXED CODE ###

def main():
    N = input()
    a = map(int, raw_input().split())
    print ' '.join(map(str,a))
    for i in xrange(1,len(a)):
        v = a[i]
        j = i - 1
        while (j >= 0) & (a[j] > v):
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v
        print ' '.join(map(str,a))
    return 0

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

sorted_data = sorted(data,key=lambda x: x[2])

def estimate_H(data,Cx,Cy):
    H = get_H(*data[0],Cx,Cy)
    for cur_data in data[1:]:
        tmp = get_H(*cur_data,Cx,Cy)
        if H != tmp:
            break
    else:
        return H
    return None
def get_H(x,y,h,Cx,Cy):
    return max(0,h+abs(x-Cx)+abs(y-Cy))

for Cx in range(101):
    for Cy in range(101):
        tmp = estimate_H(sorted_data,Cx,Cy)
        if tmp != None:
            print(Cx,Cy,tmp)
            break

### FIXED CODE ###

N = int(input())
data = [list(map(int,input().split())) for _ in range(N)]
data.sort(key=lambda x:-x[2])

def get_H(data,Cx,Cy):
    x,y,h = data
    return h+abs(x-Cx)+abs(y-Cy) , h==0
def estimate_H(data,Cx,Cy):
    H,_ = get_H(data[0],Cx,Cy)
    for cur_data in data[1:]:
        tmp,isZero = get_H(cur_data,Cx,Cy)
        if isZero and H <= tmp:
            continue
        if H != tmp:
            break
    else:
        return H
    return None

for Cx in range(101):
    for Cy in range(101):
        tmp = estimate_H(data,Cx,Cy)
        if tmp != None:
            print(Cx,Cy,tmp)
            break
X = int(input())

max = 1
for i in range(1,X+1):
    for j in range(2,i+1):
        for k in range(2,j):
            if j ** k == i:
                max = i
            if j ** k > i:
                break

print(max)


### FIXED CODE ###

input_lines = input().split()
a = int(input_lines[0])
b = int(input_lines[1])
c = int(input_lines[2])
d = int(input_lines[3])

flag = 0
if abs(c - a) > d:
    if abs(b - a) > d or abs(c - b) > d:
        flag = 1

if flag == 0:
    print("Yes")
else:
    print("No")
# Atcoder 2019/10/19
"""
# A
A, B = map(int, input().split())

ans = A - 2 * B

if ans >= 0:
    print(ans)
else:
    print(0)
"""

"""
# B
import sys
n = int(input())
d = list(map(int, sys.stdin.readline().strip().split()))

ans = 0

for i in range(n - 1):
    for j in range(i + 1, n):
        ans += d[i] * d[j]

print(ans)
"""

"""
# C
n = int(input())
s = input()

count = 1

for i in range(len(s) - 1):
    if s[i] != s[i + 1]:
        count += 1

print(count)
"""

# D
import sys

def main():
    n = int(input())
    l = list(map(int, sys.stdin.readline().strip().split()))

    global big_ans
    big_ans = []

    def angle(l, count, ans, i, n):
        if len(ans) == 3:
            big_ans.append(ans)
            return ans

        if i == n:
            # print('i end')
            return

        if len(ans) + n - i < 3:
            return

        passa = ans.copy()
        angle(l, count, passa, i + 1, n)
        ans.append(l[i])
        passb = ans.copy()
        angle(l, count + 1, passb, i + 1, n)

    angle(l, 0, [], 0, len(l))

    ans_count = 0

    for i in big_ans:
        if sum(i) - 2 * max(i) > 0:
            ans_count += 1

    print(ans_count)


if __name__ == '__main__':
    main()




### FIXED CODE ###

import sys
import bisect

n = int(input())
l = list(map(int, sys.stdin.readline().strip().split()))

l. sort()
ans = 0
for i in range(len(l)):
    for j in range(i + 1, len(l)):
        a = l[i]
        b = l[j]
        ab = a + b
        right = bisect.bisect_left(l, ab) - 1
        ans += (right - j)

print(ans)
w,a,b= map(int ,input().split())
if w>=a and b<=w+a:
    print(0)
elif a+w<=b:
    print(b-(a+w))
elif b+w<a:
    print(a(-b+w))    

### FIXED CODE ###

w,a,b= map(int ,input().split())
if w>=a and b<=w+a:
    print(0)
elif a+w<=b:
    print(b-(a+w))
elif b+w<=a:
    print(a-(b+w))
n=str(int(input()))
print(1000-int(n[1:4]))

### FIXED CODE ###

n=int(input())
print((1000-n%1000)%1000)
N = int(input())
print(int(N * (N+1) / 2)


### FIXED CODE ###

N = int(input())
print(int(N * (N+1) / 2))
S = input().split()
N = int(input())
reverse = 0
r_b = []
r_f = []
for i in range(N):
    line = input().split()
    if line[i][0] == '1' :
        reverse = (reverse + 1) % 2
    else :
        if reverse == 0 :
            if line[i][1] == '1' :
                r_f = [line[i][2]] + r_f
            else :
                r_b.append(line[i][2])
        else:
            if line[i][1] == '1':
                r_b.append(line[i][2])
            else:
                r_f = [line[i][2]] + r_f

if reverse == 0 :
    S = r_f + S + r_b
    print("".join(S))
else:
    S.reverse()
    r_b.reverse()
    r_f.reverse()
    S = r_b + S + r_f
    print("".join(S))

### FIXED CODE ###

S = input()
N = int(input())
Q = [[] for _ in range(N)]
for i in range(N):
    line = input().split()
    Q[i] = line
reverse = 0
r_b = ""
r_f = ""
for i in range(N):
    if Q[i][0] == '1' :
        reverse = (reverse + 1) % 2
    else :
        if reverse == 0 :
            if Q[i][1] == '1' :
                r_f = Q[i][2] + r_f
            else :
                r_b = r_b +Q[i][2]
        else:
            if Q[i][1] == '1':
                r_b = r_b +Q[i][2]
            else:
                r_f = Q[i][2] + r_f
if reverse == 0 :
    print(r_f + S + r_b)
else:
    r_f = r_f[::-1]
    r_b = r_b[::-1]
    S = S[::-1]
    print(r_b + S + r_f)
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():

    return
#B
def B():

    return

#C
def C():
    n = I()
    s = S()
    for i in range(n>>1):
      s[i],s[n-i-1] = s[n-i-1],s[i]
    d = defaultdict(lambda : 0)
    m = 1<<n
    for i in range(m):
        r = []
        b = []
        for j in range(n):
            if i&(1<<j):
                r.append(s[j])
            else:
                b.append(s[j])
        d[(tuple(r),tuple(b))] += 1
        
    ans = 0
    for i in range(m):
        r = []
        b = []
        for j in range(n):
            if i&(1<<j):
                r.append(s[j+n])
            else:
                b.append(s[j+n])
        ans += d[(tuple(r),tuple(b))]
    print(ans)
    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    C()


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 0
key = False
for i in range(1,n):
    if a[i] == a[i-1] and not key:
        ans += 1
        key = True
    else:
        key = False
print(ans)
n = int(input())
A = int(input())
B = int(input())

if n == 1:
    print("Hello World")
else :
    print("A+B")

### FIXED CODE ###

n = int(input())


if n == 1:
    print("Hello World")
else :
    A = int(input())
    B = int(input())
    print(A+B)
A,B = list(map(int,input().split()))
a = abs(A+B) % 2
if a == 1:
  print(IMPOSSIBLE)
else:
  print(int(abs(A+B)/2))

### FIXED CODE ###

A,B = list(map(int,input().split()))
a = abs(A+B) % 2
if a == 1:
  print("IMPOSSIBLE")
else:
  print(int(abs(A+B)/2))
w,h,n = map(int,input().split())

x = [int(i) for i in range(w+1)]
y = [int(i) for i in range(h+1)]

for i in range(n):
    x_i, y_i, a = map(int,input().split())
    if a == 1:
        x = [int(j) for j in x if j >= int(x_i)]
    elif a == 2:
        x = [int(j) for j in x if j <= int(x_i)]
    elif a == 3:
        y = [int(j) for j in y if j >= int(y_i)]
    elif a == 4:
        y = [int(j) for j in y if j <= int(y_i)]

print((max(x)-min(x)) * (max(y)-min(y)))

### FIXED CODE ###

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

x = [int(i) for i in range(w+1)]
y = [int(i) for i in range(h+1)]

for i in range(n):
    x_i, y_i, a = map(int,input().split())
    if a == 1:
        x = [int(j) for j in x if j >= int(x_i)]
    elif a == 2:
        x = [int(j) for j in x if j <= int(x_i)]
    elif a == 3:
        y = [int(j) for j in y if j >= int(y_i)]
    elif a == 4:
        y = [int(j) for j in y if j <= int(y_i)]
if len(x) == 0 or len(y) == 0:
    print('0')
else:
    print((max(x)-min(x)) * (max(y)-min(y)))
from sys import stdin
il = lambda func=int: list(map(func, stdin.readline().rstrip().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

n = int(input())
l = []
grid = [[-1] * 100 for _ in range(100)]
for i in range(n):
    a, b, c = il()
    grid[a][b] = c
    l.append(list(a, b, c))
cx, cy = 0, 0
x, y = 0, 0
hoge = []
for i in range(n):
    for j in range(n):
        if i == j: continue
        if l[i][2] == l[j][2]:
            if l[i][0] == l[j][0] or l[i][1] == l[j][1]:
                hoge.append(list(i, j))
                print((l[i][0] + l[j][0]) // 2, (l[i][1] + l[j][1]) // 2, l[1][2]+1)
                exit()
a, b = hoge[0]
if l[a][0] == l[b][0]:
    if l[a][1] + l[b][1] > 100:
        print(l[a][0], 100, l[a][2]+1)
    else:
        print(l[a][0], 0, l[a][2]+1)
else:
    if l[a][0] + l[b][0] > 100:
        print(100, l[a][1], l[a][2]+1)
    else:
        print(0, l[a][1], l[a][2]+1)

### FIXED CODE ###

from sys import stdin
il = lambda func=int: list(map(func, stdin.readline().rstrip().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

n = int(input())
l = ils(n, "il()")

for i in range(101):
    for j in range(101):
        zero = []
        height = -1
        ok = 1
        for k in range(n):
            if l[k][2] == 0:
                zero.append(k)
                continue
            if height == -1:
                height = abs(i-l[k][0]) + abs(j-l[k][1]) + l[k][2]
            if height != abs(i-l[k][0]) + abs(j-l[k][1]) + l[k][2]:
                ok = 0
                break
        for k in zero:
            if height == -1:
                height = abs(i-l[k][0]) + abs(j-l[k][1]) + l[k][2]
            if height > abs(i-l[k][0]) + abs(j-l[k][1]) + l[k][2]:
                ok = 0
                break
        if ok:
            print(i, j, height)
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)


N = I()
b = LI()

result = []
while True:
    #  print(b)
    for i in range(1, len(b)+1):
        #  print(i)
        if b[-i] == len(b)-i+1:
            #  print('break')
            result.append(b[-i])
            b.pop(b[-i])
            break
    else:
        if not b:
            break
        print(-1)
        exit()
for i in result[::-1]:
    print(i)



### FIXED CODE ###

import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)


N = I()
b = LI()

result = []
while True:
    #  print(b)
    for i in range(1, len(b)+1):
        #  print(i)
        if b[-i] == len(b)-i+1:
            #  print('break')
            result.append(b[-i])
            del b[-i]
            break
    else:
        if not b:
            break
        print(-1)
        exit()
for i in result[::-1]:
    print(i)
import sys
a = int(input())

if a >= 13:
  print(a)
  sys.exit()
elif a >= 6 and a <= 12:
  print(int(a/2))
  sys.exit()
else:
  print(0)


### FIXED CODE ###

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

if a >= 13:
  print(b)
elif a >= 6 and a <= 12:
  print(b//2)
else:
  print(0)
n,m=map(int,input().split())
l=[]
g=0
for i in range(n):
  a,b=map(int,input().split())
  a.append(l)
  b.append(l)
  
for j in range(1,n+1):
  g+=l.count(j)
  
print(g)
  

### FIXED CODE ###

n,m=map(int,input().split())
l=[]
for i in range(m):
  a,b=map(int,input().split())
  l.append(a)
  l.append(b)
  
for j in range(1,n+1):
  print(l.count(j))
R=input()
print(R*3.141592)

### FIXED CODE ###

R=float(input())
print(2*R*3.141592)
import collections
n = int(input())
a = list(map(int,input().split()))
c = sorted(collections.Counter(a).items(),reverse = True)

num2=[]
num4=[]

for k in c:
  if k[1]>=4:
    num4.append(k[0])
  if k[1]>=2:
    num2.append(k[0])

if len(num2)>=2 or len(num4)>=1:
  print(max(num2[0]*num2[1],num4[0]**2))
else:
  print(0) 

### FIXED CODE ###

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

c = sorted(collections.Counter(a).items(),reverse = True)

tmp = 0
ans=[]

for k in c:
  if k[1]>=4:
    tmp = max(tmp,k[0]*k[0])
  if k[1]>=2:
    ans.append(k[0])
  else:
    continue

if len(ans)>=2:
  print(max(ans[0]*ans[1],tmp))
else:
  print(tmp)
# ==================================================-
# 二分探索
# functionを満たす,search_listの最大の要素を出力
# 【注意点】searchリストの初めの方はfunctionを満たし、後ろに行くにつれて満たさなくなるべき
import math
import sys

sys.setrecursionlimit(10 ** 9)


def binary_research(start, end,function):
    if start == end:
        return start
    middle = math.ceil((start + end) / 2)
    if function(middle, k, a_sum, b_sum):
        start = middle
    else:
        end = middle - 1
    return binary_research(start, end, function)


# ==================================================-

n, m, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
a_sum = [0]
b_sum = [0]
for book in a:
    a_sum.append(a_sum[-1] + book)
for book in b:
    b_sum.append(b_sum[-1] + book)


def can_read(num, k, a_sum, b_sum):
    min_read_time = 1000000000000
    for i in range(max(0, num - m), n + 1):
        a_num = i
        b_num = num - i
        min_read_time = min(min_read_time, a_sum[a_num] + b_sum[b_num])
    if min_read_time <= k:
        return True
    return False


start = 0
end = n + m

print(binary_research(start, end, can_read))

### FIXED CODE ###

n,m,k=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]

def make_sumlist(book_list):
    sumnum=0
    container=[0]
    for i in book_list:
        container.append(sumnum+i)
        sumnum+=i
    return container

total_a=make_sumlist(a)
total_b=make_sumlist(b)

# print(n,m,k)
# print(total_a)
# print(total_b)


#r個読めるか
def readable(r):
    #全部読んでも無理
    if r>n+m:
        return False
    if r==0:
        return True
    max_book=100000000000
    for a_n in range(max(0,r-m),min(n,r)+1):
        b_n=r-a_n
        # print(a_n,b_n)
        book_sum=total_a[a_n]+total_b[b_n]
        # print(book_sum)
        max_book=min(max_book,book_sum)
    if max_book<=k:
        return True
    return False

def nibuntansaku(start,end):
    if start==end:
        return start
    middle=(start+end)//2+1
    if readable(middle):
        start=middle
    else:
        end=middle-1
    return nibuntansaku(start,end)

print(nibuntansaku(0,k))
five = int(input())
hand = int(input())
fives = int(input())
ans = int(input())
tmp = 0

for i in range(five):
  for j in range(hand):
    for k in range(fives):
   		ask = 500 * (i+1) + 100 * (j+1) + 50 * (k+1) 
  		if ask == ans:
       		tmp = tmp + 1

### FIXED CODE ###

five = int(input()) + 1
hand = int(input()) + 1
fives = int(input()) + 1
ans = int(input()) 
tmp = 0
 
for i in range(five):
  for j in range(hand):
    for k in range(fives):
      ask = 500 * i + 100 * j + 50 * k
      if ans == ask:
        tmp = tmp + 1

print(tmp)
# -*- coding:utf-8 -*-
import sys

def dfs(x, y, sym):
	tile[x][y] = "."
	for i in range(len(DX)):
		nx = x + DX[i]
		ny = y + DY[i]
		if 0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym:
			dfs(nx, ny, sym)

def solve():
	res = 0
	for i in range(N):
		for j in range(M):
			sym = tile[i][j]
			if tile[i][j] != ".":
				if tile[i][j] is sym:
					dfs(i, j, sym)
					res += 1
	print(res)

counter=0
DX = [-1, 0, 1, 0]
DY = [0, -1, 0, 1]
sys.setrecursionlimit(10000000)
while True:
	counter+=1
	line = input()
	if ' ' in line:
		nums = line.split(" ")
		N = int(nums[0])
		M = int(nums[1])
		tile = [[0 for i in range(N)] for j in range(M)]
	if N is 0 and M is 0:
		break
	else:
		tile[counter-2] = list(line)
	if counter-1 is M:
		solve()
		counter = 0

### FIXED CODE ###

# -*- coding:utf-8 -*-
import sys
def dfs(x, y, sym):
	tile[x][y] = "."
	for i in range(len(DX)):
		nx = x + DX[i]
		ny = y + DY[i]
		if (0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym):
			dfs(nx, ny, sym)

def solve():
	res = 0
	for i in range(N):
		for j in range(M):
			sym = tile[i][j]
			if tile[i][j] != ".":
				if tile[i][j] is sym:
					dfs(i, j, sym)
					res += 1
	print(res)

counter=0
DX = [-1,0,1,0]
DY = [0,-1,0,1]
sys.setrecursionlimit(10**7)
while True:
	line = input()
	if " " in line:
		nums = line.split(" ")
		N = int(nums[0])
		M = int(nums[1])
		tile = [[0 for i in range(M)] for j in range(N)]
	else:
		tile[counter-1] = list(line)
	if N is 0 and M is 0:
		break
	counter += 1
	if counter-1 is N:
		solve()
		counter = 0
N = input()
l = len(N)
x = int(N[0])*int(pow(10, l-1))+int('9'*(l-1))
if int(N) < x:
    x -= 1
ans = 0
while x > 0:
    ans += x%10
    x //= 10
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from copy import *

N = input()
l = len(N)
if l == 1:
    print(N)
    exit()
x = int(N[0])*int(pow(10, l-1))+int('9'*(l-1))
if int(N) < x:
    x -= 1
ans = 0
while x > 0:
    ans += x%10
    x //= 10
print(ans)
from string import ascii_lowercase
table = dict(zip(ascii_lowercase, [0 for _ in range(len(ascii_lowercase))]))
for s in input().split():
    for c in s:
        table[c.lower()] += 1
for k, v in table.items():
    print("{} : {}".format(k, v))



### FIXED CODE ###

from string import ascii_lowercase
import sys
table = dict(zip(ascii_lowercase, [0 for _ in range(len(ascii_lowercase))]))

for s in sys.stdin:
    for c in s:
        if c.lower() in table:
            table[c.lower()] += 1
for k, v in table.items():
    print("{} : {}".format(k, v))
import numpy as np

N, A, B, C = map(int,input().split())
goals = [A,B,C]
for i in range(N):
    ls.append(int(input()))

def count(x,ls):
    try:
        x.index(0)
        x.index(1)
        x.index(2)        
    except:
        return False
    A = np.zeros(len(goals))
    for i,l in enumerate(ls):
        add_ind = x[i]
        if add_ind==3:
            pass
        else:
            A[add_ind] += l
    combine_MP = 0
    for i in range(3):
        combine_MP += 10*(x.count(i)-1)
    return A, combine_MP
    
    
score_min = 100000
for N in range(4**8):
    x = []
    for j in range(len(ls)):
        x.append(N % 4)
        N = N // 4 
    try:
        A, combine_MP = count(x,ls)
        score = np.abs(A-np.array(goals)).sum() + combine_MP
        if score_min >= score:
            score_min = score
    except:
        pass
print(score_min)

### FIXED CODE ###

import numpy as np

N, A, B, C = map(int,input().split())
goals = [A,B,C]
ls = []
for i in range(N):
    ls.append(int(input()))

# goals = [1000,800,100]
# ls = [300,333,400,444,500,555,600,666]
# goals = [100, 90, 80]
# ls = [98, 40,30,21,80]

def count(x,ls):
    try:
        x.index(0)
        x.index(1)
        x.index(2)        
    except:
        return False
    A = np.zeros(len(goals))
    for i,l in enumerate(ls):
        add_ind = x[i]
        if add_ind==3:
            pass
        else:
            A[add_ind] += l
    combine_MP = 0
    for i in range(3):
        combine_MP += 10*(x.count(i)-1)
    return A, combine_MP
    
    
score_min = 100000
for N in range(4**8):
    x = []
    for j in range(len(ls)):
        x.append(N % 4)
        N = N // 4 
    try:
        A, combine_MP = count(x,ls)
        score = np.abs(A-np.array(goals)).sum() + combine_MP
        if score_min >= score:
            score_min = score
    except:
        pass
print(int(score_min))
cin = open(0).read().strip().split('\n')
n, k = map(int, cin[0].split(' '))
a = list(map(int, cin[1].split(' ')))

ret = 0
target = [a[0]+i for i in range(1, k)]
for idx in range(2**(n-1)):
    cnt = 0
    tmp = 0
    for i in range(n):
        if (idx>>i) & 1:
            tmp += target[cnt] - a[i+1] if target[cnt] > a[i+1] else 0
            cnt += 1

        if cnt == len(target):
            if ret == 0:
                ret = tmp
            else:
                ret = min(ret, tmp)
            break

print(f'{ret}\n')

### FIXED CODE ###

cin = open(0).read().strip().split('\n')
n, k = map(int, cin[0].split(' '))
a = list(map(int, cin[1].split(' ')))

ret = float('inf')
for idx in range(2**(n)):
    colors = 0
    res = 0
    left = 0
    for i in range(n):
        if (idx>>i) & 1:
            colors += 1
            res += max(left+1 - a[i] , 0)
            left += 1
        # else:
        #     colors += 1 if left < a[i] else 0

        left = max(a[i], left)

    if colors >= k:
        ret = min(ret, res)

print(ret)
from bisect import bisect_left
N, M, X = map(int, input().split())
A = sorted(list(map(int, input().split())))
index = bisect_left(A, X)
print(min(len(A[:index]), len(A[index:])))

### FIXED CODE ###

print(3*int(input())**2)
def main():
    l,r = map(int,input().split(' '))
    tmp = 2019
    if l//2019 < r//2019:
        print(0)
    else:
        for i in range(l,r):
            if tmp > (i*(i+1))%2019:
                tmp = (i*(i+1))%2019
                if tmp == 0:
        print(tmp)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    l,r = map(int,input().split(' '))
    tmp = 2019
    if l//2019 < r//2019:
        print(0)
    else:
        for i in range(l,r):
            for j in range(i+1,r+1):
                if tmp > (i*j)%2019:
                    tmp = (i*j)%2019
        print(tmp)

if __name__ == '__main__':
    main()
a=input()
b=""
for i in range(a):
  b=b+a[2*i]
print(b)

### FIXED CODE ###

a=input()
b=""
if int(len(a))%2==0:
  for i in range(int(len(a)/2)):
    b=b+a[2*i]
  print(b)
else:
  for i in range(int(len(a)/2)+1):
    b=b+a[2*i]
  print(b)