# Merge Sort
N = int(input())
lst = list(map(int, input().split()))

INF = 10**9 + 1
cnt = 0
def merge(A, left, mid, right):
    global cnt
    n1 = mid - left
    n2 = right - mid
    L = A[left:mid]
    L.append(INF)  # 番兵
    R = A[mid:right]
    R.append(INF)  # 番兵
    i, j = 0, 0
    for k in range(left, right):
        cnt += 1
        if (L[i] <= R[j]):
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
def merge_sort(A, left, right):
    if (right - left > 1):
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)
        
merge_sort(lst, 0, len(lst))
print(*lst)
print(cnt) N = int(input()) N int(input()) int input() input lst = list(map(int, input().split())) lst list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split INF = 10**9 + 1 INF 10**9 + 1 10**9 10 9 1 cnt = 0 cnt 0 def merge(A, left, mid, right):
    global cnt
    n1 = mid - left
    n2 = right - mid
    L = A[left:mid]
    L.append(INF)  # 番兵
    R = A[mid:right]
    R.append(INF)  # 番兵
    i, j = 0, 0
    for k in range(left, right):
        cnt += 1
        if (L[i] <= R[j]):
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1 merge global cnt n1 = mid - left n1 mid - left mid left n2 = right - mid n2 right - mid right mid L = A[left:mid] L A[left:mid] A left:mid left mid L.append(INF) L.append L append INF R = A[mid:right] R A[mid:right] A mid:right mid right R.append(INF) R.append R append INF i, j = 0, 0 i 0 j 0 for k in range(left, right):
        cnt += 1
        if (L[i] <= R[j]):
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1 k range(left, right) range left right cnt += 1 cnt 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 left left mid mid right right def merge_sort(A, left, right):
    if (right - left > 1):
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)
         merge_sort if (right - left > 1):
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)
         right - left > 1 right - left right left 1 mid = (left + right) // 2 mid (left + right) // 2 left + right left right 2 merge_sort(A, left, mid) merge_sort A left mid merge_sort(A, mid, right) merge_sort A mid right merge(A, left, mid, right) merge A left mid right A A left left right right merge_sort(lst, 0, len(lst)) merge_sort lst 0 len(lst) len lst print(*lst) print *lst lst print(cnt) print cnt N = int(input()) int(input()) N INF = 10**9 + 1 10**9 + 1 INF cnt = 0 0 cnt def merge(A, left, mid, right):
    global cnt
    n1 = mid - left
    n2 = right - mid
    L = A[left:mid]
    L.append(INF)  # 番兵
    R = A[mid:right]
    R.append(INF)  # 番兵
    i, j = 0, 0
    for k in range(left, right):
        cnt += 1
        if (L[i] <= R[j]):
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1 def merge(A, left, mid, right):
    global cnt
    n1 = mid - left
    n2 = right - mid
    L = A[left:mid]
    L.append(INF)  # 番兵
    R = A[mid:right]
    R.append(INF)  # 番兵
    i, j = 0, 0
    for k in range(left, right):
        cnt += 1
        if (L[i] <= R[j]):
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1 merge lst = list(map(int, input().split())) list(map(int, input().split())) lst def merge_sort(A, left, right):
    if (right - left > 1):
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)
         def merge_sort(A, left, right):
    if (right - left > 1):
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)
         merge_sort
# Merge Sort
N = int(input())
lst = list(map(int, input().split()))

INF = 10**9 + 1
cnt = 0
def merge(A, left, mid, right):
    global cnt
    n1 = mid - left
    n2 = right - mid
    L = A[left:mid]
    L.append(INF)  # 番兵
    R = A[mid:right]
    R.append(INF)  # 番兵
    i, j = 0, 0
    for k in range(left, right):
        cnt += 1
        if (L[i] <= R[j]):
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
def merge_sort(A, left, right):
    if (right - left > 1):
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)
        
merge_sort(lst, 0, len(lst))
print(*lst)
print(cnt)
