count=0
def mg(S,left,right,mid):
    global count
    L=[]
    L=S[left:mid]
    L.append(9999999999)
    R=[]
    R=S[mid:right]
    R.append(9999999999)
    r=0
    l=0
    for i in range(left,right):
        count=count+1
        if L[l]<=R[r]:
            S[i]=L[l]
            l=l+1
        else:
            S[i]=R[r]
            r=r+1
def ms(S,left,right):
    if right>left+1:
        mid=(right+left)//2
        ms(S,left,mid)
        ms(S,mid,right)
        mg(S,left,right,mid)
n=int(input())
S=[]
S=input().split()
S=[int(u) for u in S]
ms(S,0,n)
for i in range(0,n-1):
    print(S[i],end=" ")
print(S[n-1])
print(count) count=0 count 0 def mg(S,left,right,mid):
    global count
    L=[]
    L=S[left:mid]
    L.append(9999999999)
    R=[]
    R=S[mid:right]
    R.append(9999999999)
    r=0
    l=0
    for i in range(left,right):
        count=count+1
        if L[l]<=R[r]:
            S[i]=L[l]
            l=l+1
        else:
            S[i]=R[r]
            r=r+1 mg global count L=[] L [] L=S[left:mid] L S[left:mid] S left:mid left mid L.append(9999999999) L.append L append 9999999999 R=[] R [] R=S[mid:right] R S[mid:right] S mid:right mid right R.append(9999999999) R.append R append 9999999999 r=0 r 0 l=0 l 0 for i in range(left,right):
        count=count+1
        if L[l]<=R[r]:
            S[i]=L[l]
            l=l+1
        else:
            S[i]=R[r]
            r=r+1 i range(left,right) range left right count=count+1 count count+1 count 1 if L[l]<=R[r]:
            S[i]=L[l]
            l=l+1
        else:
            S[i]=R[r]
            r=r+1 L[l]<=R[r] L[l] L l R[r] R r S[i]=L[l] S[i] S i L[l] L l l=l+1 l l+1 l 1 S[i]=R[r] S[i] S i R[r] R r r=r+1 r r+1 r 1 S S left left right right mid mid def ms(S,left,right):
    if right>left+1:
        mid=(right+left)//2
        ms(S,left,mid)
        ms(S,mid,right)
        mg(S,left,right,mid) ms if right>left+1:
        mid=(right+left)//2
        ms(S,left,mid)
        ms(S,mid,right)
        mg(S,left,right,mid) right>left+1 right left+1 left 1 mid=(right+left)//2 mid (right+left)//2 right+left right left 2 ms(S,left,mid) ms S left mid ms(S,mid,right) ms S mid right mg(S,left,right,mid) mg S left right mid S S left left right right n=int(input()) n int(input()) int input() input S=[] S [] S=input().split() S input().split() ().split () input split int(u) for u in S for u in S u S for u in S int(u) int u S=[int(u) for u in S] S [int(u) for u in S] ms(S,0,n) ms S 0 n for i in range(0,n-1):
    print(S[i],end=" ") i range(0,n-1) range 0 n-1 n 1 print(S[i],end=" ") print S[i] S i end=" " end " " print(S[n-1]) print S[n-1] S n-1 n 1 print(count) print count def ms(S,left,right):
    if right>left+1:
        mid=(right+left)//2
        ms(S,left,mid)
        ms(S,mid,right)
        mg(S,left,right,mid) def ms(S,left,right):
    if right>left+1:
        mid=(right+left)//2
        ms(S,left,mid)
        ms(S,mid,right)
        mg(S,left,right,mid) ms count=0 0 count S=[] [] S S=[int(u) for u in S] [int(u) for u in S] S n=int(input()) int(input()) n S=input().split() input().split() S def mg(S,left,right,mid):
    global count
    L=[]
    L=S[left:mid]
    L.append(9999999999)
    R=[]
    R=S[mid:right]
    R.append(9999999999)
    r=0
    l=0
    for i in range(left,right):
        count=count+1
        if L[l]<=R[r]:
            S[i]=L[l]
            l=l+1
        else:
            S[i]=R[r]
            r=r+1 def mg(S,left,right,mid):
    global count
    L=[]
    L=S[left:mid]
    L.append(9999999999)
    R=[]
    R=S[mid:right]
    R.append(9999999999)
    r=0
    l=0
    for i in range(left,right):
        count=count+1
        if L[l]<=R[r]:
            S[i]=L[l]
            l=l+1
        else:
            S[i]=R[r]
            r=r+1 mg
count=0
def mg(S,left,right,mid):
    global count
    L=[]
    L=S[left:mid]
    L.append(9999999999)
    R=[]
    R=S[mid:right]
    R.append(9999999999)
    r=0
    l=0
    for i in range(left,right):
        count=count+1
        if L[l]<=R[r]:
            S[i]=L[l]
            l=l+1
        else:
            S[i]=R[r]
            r=r+1
def ms(S,left,right):
    if right>left+1:
        mid=(right+left)//2
        ms(S,left,mid)
        ms(S,mid,right)
        mg(S,left,right,mid)
n=int(input())
S=[]
S=input().split()
S=[int(u) for u in S]
ms(S,0,n)
for i in range(0,n-1):
    print(S[i],end=" ")
print(S[n-1])
print(count)
