c = 0

def merge(A, l, m, r):
  global c
  L = A[l:m]
  L.append(1e10)
  R = A[m:r]
  R.append(1e10)
  i, j = 0, 0
  for k in range(l, r):
    c += 1
    if L[i] <= R[j]:
      A[k] = L[i]
      i += 1
    else:
      A[k] = R[j]
      j += 1

def sort(A, l, r):
  if r-l > 1:
    m = (l+r)//2
    sort(A, l, m)
    sort(A, m, r)
    merge(A, l, m, r)

N = int(input())
A = list(map(int, input().split()))
sort(A, 0, N)
print(" ".join(map(str, A)))
print(c) c = 0 c 0 def merge(A, l, m, r):
  global c
  L = A[l:m]
  L.append(1e10)
  R = A[m:r]
  R.append(1e10)
  i, j = 0, 0
  for k in range(l, r):
    c += 1
    if L[i] <= R[j]:
      A[k] = L[i]
      i += 1
    else:
      A[k] = R[j]
      j += 1 merge global c L = A[l:m] L A[l:m] A l:m l m L.append(1e10) L.append L append 1e10 R = A[m:r] R A[m:r] A m:r m r R.append(1e10) R.append R append 1e10 i, j = 0, 0 i 0 j 0 for k in range(l, r):
    c += 1
    if L[i] <= R[j]:
      A[k] = L[i]
      i += 1
    else:
      A[k] = R[j]
      j += 1 k range(l, r) range l r c += 1 c 1 if L[i] <= R[j]:
      A[k] = L[i]
      i += 1
    else:
      A[k] = R[j]
      j += 1 L[i] <= R[j] L[i] L i R[j] R j A[k] = L[i] A[k] A k L[i] L i i += 1 i 1 A[k] = R[j] A[k] A k R[j] R j j += 1 j 1 A A l l m m r r def sort(A, l, r):
  if r-l > 1:
    m = (l+r)//2
    sort(A, l, m)
    sort(A, m, r)
    merge(A, l, m, r) sort if r-l > 1:
    m = (l+r)//2
    sort(A, l, m)
    sort(A, m, r)
    merge(A, l, m, r) r-l > 1 r-l r l 1 m = (l+r)//2 m (l+r)//2 l+r l r 2 sort(A, l, m) sort A l m sort(A, m, r) sort A m r merge(A, l, m, r) merge A l m r A A l l r r N = int(input()) N int(input()) int input() input A = list(map(int, input().split())) A list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split sort(A, 0, N) sort A 0 N print(" ".join(map(str, A))) print " ".join(map(str, A)) " ".join " " join map(str, A) map str A print(c) print c def merge(A, l, m, r):
  global c
  L = A[l:m]
  L.append(1e10)
  R = A[m:r]
  R.append(1e10)
  i, j = 0, 0
  for k in range(l, r):
    c += 1
    if L[i] <= R[j]:
      A[k] = L[i]
      i += 1
    else:
      A[k] = R[j]
      j += 1 def merge(A, l, m, r):
  global c
  L = A[l:m]
  L.append(1e10)
  R = A[m:r]
  R.append(1e10)
  i, j = 0, 0
  for k in range(l, r):
    c += 1
    if L[i] <= R[j]:
      A[k] = L[i]
      i += 1
    else:
      A[k] = R[j]
      j += 1 merge N = int(input()) int(input()) N def sort(A, l, r):
  if r-l > 1:
    m = (l+r)//2
    sort(A, l, m)
    sort(A, m, r)
    merge(A, l, m, r) def sort(A, l, r):
  if r-l > 1:
    m = (l+r)//2
    sort(A, l, m)
    sort(A, m, r)
    merge(A, l, m, r) sort c = 0 0 c A = list(map(int, input().split())) list(map(int, input().split())) A
c = 0

def merge(A, l, m, r):
  global c
  L = A[l:m]
  L.append(1e10)
  R = A[m:r]
  R.append(1e10)
  i, j = 0, 0
  for k in range(l, r):
    c += 1
    if L[i] <= R[j]:
      A[k] = L[i]
      i += 1
    else:
      A[k] = R[j]
      j += 1

def sort(A, l, r):
  if r-l > 1:
    m = (l+r)//2
    sort(A, l, m)
    sort(A, m, r)
    merge(A, l, m, r)

N = int(input())
A = list(map(int, input().split()))
sort(A, 0, N)
print(" ".join(map(str, A)))
print(c)
