cnt = 0
n = int(input())
S = list(map(int, input().split()))

def mergeSort(S, left, right):
  if left+1 < right:
    mid = (left + right) // 2
    mergeSort(S, left, mid)
    mergeSort(S, mid, right)
    merge(S, left, mid, right)

def merge(S, left, mid, right):

  L = S[left:mid] + [10**10]
  R = S[mid:right] + [10**10]

  i,j = 0,0

  global cnt
  for k in range(left, right):
    cnt += 1
    if L[i] <= R[j]:
      S[k] = L[i]
      i += 1
    else:
      S[k] = R[j]
      j += 1

mergeSort(S, 0, len(S))
print (' '.join(map(str,S)))
print (cnt) cnt = 0 cnt 0 n = int(input()) n int(input()) int input() input S = list(map(int, input().split())) S list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split def mergeSort(S, left, right):
  if left+1 < right:
    mid = (left + right) // 2
    mergeSort(S, left, mid)
    mergeSort(S, mid, right)
    merge(S, left, mid, right) mergeSort if left+1 < right:
    mid = (left + right) // 2
    mergeSort(S, left, mid)
    mergeSort(S, mid, right)
    merge(S, left, mid, right) left+1 < right left+1 left 1 right mid = (left + right) // 2 mid (left + right) // 2 left + right left right 2 mergeSort(S, left, mid) mergeSort S left mid mergeSort(S, mid, right) mergeSort S mid right merge(S, left, mid, right) merge S left mid right S S left left right right def merge(S, left, mid, right):

  L = S[left:mid] + [10**10]
  R = S[mid:right] + [10**10]

  i,j = 0,0

  global cnt
  for k in range(left, right):
    cnt += 1
    if L[i] <= R[j]:
      S[k] = L[i]
      i += 1
    else:
      S[k] = R[j]
      j += 1 merge L = S[left:mid] + [10**10] L S[left:mid] + [10**10] S[left:mid] S left:mid left mid [10**10] 10**10 10 10 R = S[mid:right] + [10**10] R S[mid:right] + [10**10] S[mid:right] S mid:right mid right [10**10] 10**10 10 10 i,j = 0,0 i 0 j 0 global cnt for k in range(left, right):
    cnt += 1
    if L[i] <= R[j]:
      S[k] = L[i]
      i += 1
    else:
      S[k] = R[j]
      j += 1 k range(left, right) range left right cnt += 1 cnt 1 if L[i] <= R[j]:
      S[k] = L[i]
      i += 1
    else:
      S[k] = R[j]
      j += 1 L[i] <= R[j] L[i] L i R[j] R j S[k] = L[i] S[k] S k L[i] L i i += 1 i 1 S[k] = R[j] S[k] S k R[j] R j j += 1 j 1 S S left left mid mid right right mergeSort(S, 0, len(S)) mergeSort S 0 len(S) len S print (' '.join(map(str,S))) print ' '.join(map(str,S)) ' '.join ' ' join map(str,S) map str S print (cnt) print cnt n = int(input()) int(input()) n cnt = 0 0 cnt def merge(S, left, mid, right):

  L = S[left:mid] + [10**10]
  R = S[mid:right] + [10**10]

  i,j = 0,0

  global cnt
  for k in range(left, right):
    cnt += 1
    if L[i] <= R[j]:
      S[k] = L[i]
      i += 1
    else:
      S[k] = R[j]
      j += 1 def merge(S, left, mid, right):

  L = S[left:mid] + [10**10]
  R = S[mid:right] + [10**10]

  i,j = 0,0

  global cnt
  for k in range(left, right):
    cnt += 1
    if L[i] <= R[j]:
      S[k] = L[i]
      i += 1
    else:
      S[k] = R[j]
      j += 1 merge S = list(map(int, input().split())) list(map(int, input().split())) S def mergeSort(S, left, right):
  if left+1 < right:
    mid = (left + right) // 2
    mergeSort(S, left, mid)
    mergeSort(S, mid, right)
    merge(S, left, mid, right) def mergeSort(S, left, right):
  if left+1 < right:
    mid = (left + right) // 2
    mergeSort(S, left, mid)
    mergeSort(S, mid, right)
    merge(S, left, mid, right) mergeSort
cnt = 0
n = int(input())
S = list(map(int, input().split()))

def mergeSort(S, left, right):
  if left+1 < right:
    mid = (left + right) // 2
    mergeSort(S, left, mid)
    mergeSort(S, mid, right)
    merge(S, left, mid, right)

def merge(S, left, mid, right):

  L = S[left:mid] + [10**10]
  R = S[mid:right] + [10**10]

  i,j = 0,0

  global cnt
  for k in range(left, right):
    cnt += 1
    if L[i] <= R[j]:
      S[k] = L[i]
      i += 1
    else:
      S[k] = R[j]
      j += 1

mergeSort(S, 0, len(S))
print (' '.join(map(str,S)))
print (cnt)
