def m(L,R):
 global c
 T=[];i=j=0
 for _ in L[:-1]+R[:-1]:
  if L[i]<R[j]:T+=[L[i]];i+=1
  else:T+=[R[j]];j+=1
  c+=1
 return T
def d(A):s=len(A)//2;return m(d(A[:s])+[1e9],d(A[s:])+[1e9]) if len(A)>1 else A
c=0
input()
print(*d(list(map(int,input().split()))))
print(c) def m(L,R):
 global c
 T=[];i=j=0
 for _ in L[:-1]+R[:-1]:
  if L[i]<R[j]:T+=[L[i]];i+=1
  else:T+=[R[j]];j+=1
  c+=1
 return T m global c T=[] T [] i=j=0 i 0 =j=0 j 0 for _ in L[:-1]+R[:-1]:
  if L[i]<R[j]:T+=[L[i]];i+=1
  else:T+=[R[j]];j+=1
  c+=1
  _ L[:-1]+R[:-1] L[:-1] L :-1 -1 R[:-1] R :-1 -1 if L[i]<R[j]:T+=[L[i]];i+=1
  else:T+=[R[j]];j+=1
   L[i]<R[j] L[i] L i R[j] R j c+=1 c 1 return T T L L R R def d(A):s=len(A)//2;return m(d(A[:s])+[1e9],d(A[s:])+[1e9]) if len(A)>1 else A d A A c=0 c 0 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 def m(L,R):
 global c
 T=[];i=j=0
 for _ in L[:-1]+R[:-1]:
  if L[i]<R[j]:T+=[L[i]];i+=1
  else:T+=[R[j]];j+=1
  c+=1
 return T def m(L,R):
 global c
 T=[];i=j=0
 for _ in L[:-1]+R[:-1]:
  if L[i]<R[j]:T+=[L[i]];i+=1
  else:T+=[R[j]];j+=1
  c+=1
 return T m c=0 0 c def d(A):s=len(A)//2;return m(d(A[:s])+[1e9],d(A[s:])+[1e9]) if len(A)>1 else A def d(A):s=len(A)//2;return m(d(A[:s])+[1e9],d(A[s:])+[1e9]) if len(A)>1 else A d
def m(L,R):
 global c
 T=[];i=j=0
 for _ in L[:-1]+R[:-1]:
  if L[i]<R[j]:T+=[L[i]];i+=1
  else:T+=[R[j]];j+=1
  c+=1
 return T
def d(A):s=len(A)//2;return m(d(A[:s])+[1e9],d(A[s:])+[1e9]) if len(A)>1 else A
c=0
input()
print(*d(list(map(int,input().split()))))
print(c)
