n,*a=map(int,open(0).read().split())

c=0
left=0
right=n
def merge(A,left,mid,right):
    global c
    L=A[left:mid]+[float("inf")]
    R=A[mid:right]+[float("inf")]
    i=0
    j=0
    for r in range(left,right):
        if L[j]>R[i]:
            c+=1
            A[r]=R[i]
            i+=1
        else:
            c+=1
            A[r]=L[j]
            j+=1

def mergesort(A,left,right):
    if left+1<right:
        mid=(left+right)//2
        mergesort(A,left,mid)
        mergesort(A,mid,right)
        merge(A,left,mid,right)
        
mergesort(a,left,right)

print(*a)
print(c) n,*a=map(int,open(0).read().split()) n map(int,open(0).read().split()) map int open(0).read().split() (0).read().split (0).read() (0).read (0) open 0 read split *a a c=0 c 0 left=0 left 0 right=n right n def merge(A,left,mid,right):
    global c
    L=A[left:mid]+[float("inf")]
    R=A[mid:right]+[float("inf")]
    i=0
    j=0
    for r in range(left,right):
        if L[j]>R[i]:
            c+=1
            A[r]=R[i]
            i+=1
        else:
            c+=1
            A[r]=L[j]
            j+=1 merge global c L=A[left:mid]+[float("inf")] L A[left:mid]+[float("inf")] A[left:mid] A left:mid left mid [float("inf")] float("inf") float "inf" R=A[mid:right]+[float("inf")] R A[mid:right]+[float("inf")] A[mid:right] A mid:right mid right [float("inf")] float("inf") float "inf" i=0 i 0 j=0 j 0 for r in range(left,right):
        if L[j]>R[i]:
            c+=1
            A[r]=R[i]
            i+=1
        else:
            c+=1
            A[r]=L[j]
            j+=1 r range(left,right) range left right if L[j]>R[i]:
            c+=1
            A[r]=R[i]
            i+=1
        else:
            c+=1
            A[r]=L[j]
            j+=1 L[j]>R[i] L[j] L j R[i] R i c+=1 c 1 A[r]=R[i] A[r] A r R[i] R i i+=1 i 1 c+=1 c 1 A[r]=L[j] A[r] A r L[j] L j j+=1 j 1 A A left left mid mid right right def mergesort(A,left,right):
    if left+1<right:
        mid=(left+right)//2
        mergesort(A,left,mid)
        mergesort(A,mid,right)
        merge(A,left,mid,right)
         mergesort if left+1<right:
        mid=(left+right)//2
        mergesort(A,left,mid)
        mergesort(A,mid,right)
        merge(A,left,mid,right)
         left+1<right left+1 left 1 right mid=(left+right)//2 mid (left+right)//2 left+right left right 2 mergesort(A,left,mid) mergesort A left mid mergesort(A,mid,right) mergesort A mid right merge(A,left,mid,right) merge A left mid right A A left left right right mergesort(a,left,right) mergesort a left right print(*a) print *a a print(c) print c def mergesort(A,left,right):
    if left+1<right:
        mid=(left+right)//2
        mergesort(A,left,mid)
        mergesort(A,mid,right)
        merge(A,left,mid,right)
         def mergesort(A,left,right):
    if left+1<right:
        mid=(left+right)//2
        mergesort(A,left,mid)
        mergesort(A,mid,right)
        merge(A,left,mid,right)
         mergesort n,*a=map(int,open(0).read().split()) map(int,open(0).read().split()) n c=0 0 c left=0 0 left def merge(A,left,mid,right):
    global c
    L=A[left:mid]+[float("inf")]
    R=A[mid:right]+[float("inf")]
    i=0
    j=0
    for r in range(left,right):
        if L[j]>R[i]:
            c+=1
            A[r]=R[i]
            i+=1
        else:
            c+=1
            A[r]=L[j]
            j+=1 def merge(A,left,mid,right):
    global c
    L=A[left:mid]+[float("inf")]
    R=A[mid:right]+[float("inf")]
    i=0
    j=0
    for r in range(left,right):
        if L[j]>R[i]:
            c+=1
            A[r]=R[i]
            i+=1
        else:
            c+=1
            A[r]=L[j]
            j+=1 merge right=n n right
n,*a=map(int,open(0).read().split())

c=0
left=0
right=n
def merge(A,left,mid,right):
    global c
    L=A[left:mid]+[float("inf")]
    R=A[mid:right]+[float("inf")]
    i=0
    j=0
    for r in range(left,right):
        if L[j]>R[i]:
            c+=1
            A[r]=R[i]
            i+=1
        else:
            c+=1
            A[r]=L[j]
            j+=1

def mergesort(A,left,right):
    if left+1<right:
        mid=(left+right)//2
        mergesort(A,left,mid)
        mergesort(A,mid,right)
        merge(A,left,mid,right)
        
mergesort(a,left,right)

print(*a)
print(c)
