#include <stdio.h>

#define N 500000
#define E 1000000000

void Merge(int *,int ,int , int);
void MergeSort(int *,int , int);

int count=0;

void MergeSort(int *S,int left,int right){
  int mid=0;
  
  if(left+1 < right){
    mid = (left+right)/2;
    MergeSort(S,left,mid);
    MergeSort(S,mid,right);
    Merge(S,left,mid,right);
  }
}


void Merge(int *S,int left,int mid,int right){
  int n1=mid - left,n2=right - mid;
  int L[n1],R[n2];
  int i,j,k=0;
  
  for(i=0;i < n1;i++){
    L[i] = S[left+i];
  }
  
  for(j=0;j < n2;j++){
    R[j] = S[mid+j];  
  }

  L[n1] = E;
  R[n2] = E;
  
  i = 0;
  j = 0;
  
  for(k = left;k < right;k++){
    if(L[i] <= R[j]){
      S[k] = L[i];
      i = i+1;
      count++;
    } 
    
    else{
      S[k] = R[j];
      j = j+1;
      count++;
    }
  }
}


main() {
  int i;  
  int n=0;
  int S[N];
  
  scanf("%d",&n);
  
  if(N < n){
    return 0;
  }
  
  for(i=0;i < n;i++){
    scanf("%d",&S[i]);
    
    if(E < S[i]){
      return 0;
    }
  }
  
  MergeSort(S,0,n);
  
  for(i=0;i < n;i++){
    printf("%d ",S[i]);
  }
  printf("\n");
  printf("%d\n",count);

  return 0;
} 