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