global cmt                                                     
cmt = 0                                                        
def Merge(left, right):                                        
    global cmt                                                 
    lst = []                                                   
    i, j = 0, 0                                                
    while i < len(left) and j < len(right):                    
        if left[i] <= right[j]:                                
            lst.append(left[i])                                
            i += 1                                             
        else:                                                  
            lst.append(right[j])                               
            j += 1                                             
    lst += left[i:]                                            
    lst += right[j:]                                           
    cmt += len(lst)                                            
                                                               
    return lst                                                 
                                                               
def MergeSort(A):                                              
    if len(A) == 1: return A                                   
    mid = len(A) / 2                                           
    left = MergeSort(A[:mid])                                  
    right = MergeSort(A[mid:])                                 
    #print left, right                                         
    sortedList = Merge(left, right)                            
    return sortedList                                          
                                                               
n = raw_input()                                                
print ' '.join(map(str,MergeSort(map(int, raw_input().split()))
))                                                             
print cmt global cmt cmt = 0 cmt 0 def Merge(left, right):                                        
    global cmt                                                 
    lst = []                                                   
    i, j = 0, 0                                                
    while i < len(left) and j < len(right):                    
        if left[i] <= right[j]:                                
            lst.append(left[i])                                
            i += 1                                             
        else:                                                  
            lst.append(right[j])                               
            j += 1                                             
    lst += left[i:]                                            
    lst += right[j:]                                           
    cmt += len(lst)                                            
                                                               
    return lst                                                 
                                                                Merge global cmt lst = [] lst [] i, j = 0, 0 i 0 j 0 while i < len(left) and j < len(right):                    
        if left[i] <= right[j]:                                
            lst.append(left[i])                                
            i += 1                                             
        else:                                                  
            lst.append(right[j])                               
            j += 1                                             
     i < len(left) and j < len(right) i < len(left) i len(left) len left j < len(right) j len(right) len right if left[i] <= right[j]:                                
            lst.append(left[i])                                
            i += 1                                             
        else:                                                  
            lst.append(right[j])                               
            j += 1                                             
     left[i] <= right[j] left[i] left i right[j] right j lst.append(left[i]) lst.append lst append left[i] left i i += 1 i 1 lst.append(right[j]) lst.append lst append right[j] right j j += 1 j 1 lst += left[i:] lst left[i:] left i: i lst += right[j:] lst right[j:] right j: j cmt += len(lst) cmt len(lst) len lst return lst lst left left right right def MergeSort(A):                                              
    if len(A) == 1: return A                                   
    mid = len(A) / 2                                           
    left = MergeSort(A[:mid])                                  
    right = MergeSort(A[mid:])                                 
    #print left, right                                         
    sortedList = Merge(left, right)                            
    return sortedList                                          
                                                                MergeSort if len(A) == 1: return A                                   
     len(A) == 1 len(A) len A 1 mid = len(A) / 2 mid len(A) / 2 len(A) len A 2 left = MergeSort(A[:mid]) left MergeSort(A[:mid]) MergeSort A[:mid] A :mid mid right = MergeSort(A[mid:]) right MergeSort(A[mid:]) MergeSort A[mid:] A mid: mid sortedList = Merge(left, right) sortedList Merge(left, right) Merge left right return sortedList sortedList A A n = raw_input() n raw_input() raw_input print ' '.join(map(str,MergeSort(map(int, raw_input().split()))
)) ' '.join ' ' join map(str,MergeSort(map(int, raw_input().split()))
) map str MergeSort(map(int, raw_input().split())) MergeSort map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split print def Merge(left, right):                                        
    global cmt                                                 
    lst = []                                                   
    i, j = 0, 0                                                
    while i < len(left) and j < len(right):                    
        if left[i] <= right[j]:                                
            lst.append(left[i])                                
            i += 1                                             
        else:                                                  
            lst.append(right[j])                               
            j += 1                                             
    lst += left[i:]                                            
    lst += right[j:]                                           
    cmt += len(lst)                                            
                                                               
    return lst                                                 
                                                                def Merge(left, right):                                        
    global cmt                                                 
    lst = []                                                   
    i, j = 0, 0                                                
    while i < len(left) and j < len(right):                    
        if left[i] <= right[j]:                                
            lst.append(left[i])                                
            i += 1                                             
        else:                                                  
            lst.append(right[j])                               
            j += 1                                             
    lst += left[i:]                                            
    lst += right[j:]                                           
    cmt += len(lst)                                            
                                                               
    return lst                                                 
                                                                Merge def MergeSort(A):                                              
    if len(A) == 1: return A                                   
    mid = len(A) / 2                                           
    left = MergeSort(A[:mid])                                  
    right = MergeSort(A[mid:])                                 
    #print left, right                                         
    sortedList = Merge(left, right)                            
    return sortedList                                          
                                                                def MergeSort(A):                                              
    if len(A) == 1: return A                                   
    mid = len(A) / 2                                           
    left = MergeSort(A[:mid])                                  
    right = MergeSort(A[mid:])                                 
    #print left, right                                         
    sortedList = Merge(left, right)                            
    return sortedList                                          
                                                                MergeSort global cmt cmt = 0 0 cmt n = raw_input() raw_input() n
global cmt                                                     
cmt = 0                                                        
def Merge(left, right):                                        
    global cmt                                                 
    lst = []                                                   
    i, j = 0, 0                                                
    while i < len(left) and j < len(right):                    
        if left[i] <= right[j]:                                
            lst.append(left[i])                                
            i += 1                                             
        else:                                                  
            lst.append(right[j])                               
            j += 1                                             
    lst += left[i:]                                            
    lst += right[j:]                                           
    cmt += len(lst)                                            
                                                               
    return lst                                                 
                                                               
def MergeSort(A):                                              
    if len(A) == 1: return A                                   
    mid = len(A) / 2                                           
    left = MergeSort(A[:mid])                                  
    right = MergeSort(A[mid:])                                 
    #print left, right                                         
    sortedList = Merge(left, right)                            
    return sortedList                                          
                                                               
n = raw_input()                                                
print ' '.join(map(str,MergeSort(map(int, raw_input().split()))
))                                                             
print cmt