#include<stdio.h>
#include<stdlib.h>
#define SENTINEL 100000
int Merge(int,int,int);
int Merge_Sort(int,int);
 int S[SENTINEL];
int A[SENTINEL];
int L[SENTINEL];
int R[SENTINEL];
int n,count = 0;

main(){
  int left,right,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  left = 0;
  right = n;
 
  Merge_Sort(left,right);

for(i=0;i<n-1;i++){
  printf("%d ",S[i]);
 }
 printf("%d",S[n-1]); 
 printf("\n");
 printf("%d\n",count);
 return 0;
}
int Merge(int left,int mid,int right){
  int n1,n2,i,j,k;