
#include <stdio.h>
#define max 500000  
int L[250002];
int R[250002];
int c;
int merge(int S[], int n, int l, int m, int r){
int i, j, k;      
int n1 = m-l;
int n2 = r-m;
for (i = 0; i < n1; i++)
L[i] = S[l+i];
for (i = 0; i < n2; i++)
R[i] = S[m+i];
L[n1] = R[n2] = 2000000000;
i = j = 0;
for ( k = l; k < r; k++){
c++;
if ( L[i] <= R[j]){
S[k] = L[i]; 
i++;
}
else{
S[k] = R[j];
j++;}
}
}
void mergeSort(int S[], int n, int l, int r){
if (l+1<r){
int m = (l+r) / 2;
mergeSort(S,n, l,m);
mergeSort(S, n,m,r);
merge(S,n, l,m,r);
}
}
int main(void){
int S[max], n, i,c=0;

scanf("%d", &n);
for (i = 0; i < n; i++) 
scanf("%d", &S[i]); 
mergeSort(S, n, 0, n);
for (i = 0; i < n; i++){
if(i==0){
printf("%d", S[i]);}
else {
printf(" %d", S[i]);}
}
printf("\n%d\n", c);

return 0;
}