#include<stdio.h>

void merge(int *a, int left, int mid, int right, int *c){
   int n1, n2, i, j, k;
   int L[500000] = {1000000000};
   int R[500000] = {1000000000}};

   n1 = mid - left;
   n2 = right - mid;

   for(i = 0; i < n1; i++){
      L[i] = a[left + i];
   }
   for(i = 0; i < n2; i++){
      R[i] = a[mid + i];
   }

   i = 0;
   j = 0;

   for(k = left; k < right; k++){
      if(L[i] <= R[j]){
         a[k] = L[i];
         i++;
      }else{
         a[k] = R[j];
         j++;
      }
   }
   c++;

}





void mergeSort(int *a, int left, int right, int *c){

   if(left + 1 < right){
      mid = (left + right) / 2;
      mergeSort(a, left, mid, c);
      mergeSort(a, mid, right, c);
      merge(a, left, mid, right, c);
   }

}

int main (){
   int n, i, count;
   int s[500000] = {0};

   scanf("%d", &n);

   for(i = 0; i < n; i++){
      scanf("%d", &a[i]);
   }

   mergeSort(s, 0, n-1, count);

   for(i = 0; i < n; i++){
      if(i)
         printf(" ");
      printf("%d", s[i]);
   }
   printf("\n%d\n", count);

   return 0;

}