def m(L,R):
 T=[]
 for l in L[::-1]:
  while R and R[-1]>l:T+=[R.pop()]
  T+=[l]
 return R+T[::-1]
def d(A):
 l=len(A);global c;c+=l
 s=l//2;return m(d(A[:s]),d(A[s:]))if l>1 else A
c=-int(input())
print(*d(list(map(int,input().split()))))
print(c) def m(L,R):
 T=[]
 for l in L[::-1]:
  while R and R[-1]>l:T+=[R.pop()]
  T+=[l]
 return R+T[::-1] m T=[] T [] for l in L[::-1]:
  while R and R[-1]>l:T+=[R.pop()]
  T+=[l]
  l L[::-1] L ::-1 -1 while R and R[-1]>l:T+=[R.pop()]
   R and R[-1]>l R R[-1]>l R[-1] R -1 l T+=[l] T [l] l return R+T[::-1] R+T[::-1] R T[::-1] T ::-1 -1 L L R R def d(A):
 l=len(A);global c;c+=l
 s=l//2;return m(d(A[:s]),d(A[s:]))if l>1 else A d l=len(A) l len(A) len A global c c+=l c l s=l//2 s l//2 l 2 return m(d(A[:s]),d(A[s:]))if l>1 else A m(d(A[:s]),d(A[s:]))if l>1 else A l>1 l 1 m(d(A[:s]),d(A[s:])) m d(A[:s]) d A[:s] A :s s d(A[s:]) d A[s:] A s: s A A A c=-int(input()) c -int(input()) int(input()) int input() input print(*d(list(map(int,input().split())))) print *d(list(map(int,input().split()))) d(list(map(int,input().split()))) d list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split print(c) print c c=-int(input()) -int(input()) c def m(L,R):
 T=[]
 for l in L[::-1]:
  while R and R[-1]>l:T+=[R.pop()]
  T+=[l]
 return R+T[::-1] def m(L,R):
 T=[]
 for l in L[::-1]:
  while R and R[-1]>l:T+=[R.pop()]
  T+=[l]
 return R+T[::-1] m def d(A):
 l=len(A);global c;c+=l
 s=l//2;return m(d(A[:s]),d(A[s:]))if l>1 else A def d(A):
 l=len(A);global c;c+=l
 s=l//2;return m(d(A[:s]),d(A[s:]))if l>1 else A d
def m(L,R):
 T=[]
 for l in L[::-1]:
  while R and R[-1]>l:T+=[R.pop()]
  T+=[l]
 return R+T[::-1]
def d(A):
 l=len(A);global c;c+=l
 s=l//2;return m(d(A[:s]),d(A[s:]))if l>1 else A
c=-int(input())
print(*d(list(map(int,input().split()))))
print(c)
