#include <stdio.h>
#include <stdlib.h>
#define INF 10000000
#define MAX 500001

int n = 0;

void Merge (int *A, int l, int m, int r ) {
  int n1 = m - l;
  int n2 = r - m;
  n++;

  int *a = (int *)malloc(sizeof(int) * (n1 + 1));
  int *b = (int *)malloc(sizeof(int) * (n2 + 1));

  for (int i = 0; i < n1; i++) {
    a[i] = A[l+i];
  }

  for (int i = 0; i < n2; i++) {
    b[i] = A[m+i];
  }

  a[n1] = INF;
  b[n2] = INF;

  int i = 0;
  int j = 0;

  for (int k = l; k < r; i++) {
    if (a[i] <= b[j]) {
      A[k] = a[i];
      i++;
    }else {
      A[k] = b[j];
      j++;
    }
  }
  free(a);
  free(b);
}

void Merge_Sort (int *A, int l, int r) {
  if (l + 1 < r) {
    int m = (l + r) / 2;
    Merge_Sort(A, l, m);
    Merge_Sort(A, m, r);
    Merge(A, l, m, r);
  }
}

int main () {
  int s;
  int A[MAX];
  scanf("%d", &s);
  for (int i = 0; i < s; i++) {
    scanf("%d", &A[i]);
  }
  Merge_Sort(A, 0, s-1);

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

  return 0;
}