N = int(input())
num_list = [int(item) for item in input().split()]


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

    L = A[left : mid] + [100**5]
    R = A[mid: right] + [100**5]
 
    cnt = 0
    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
        # print(A, left, mid, right)
    return cnt


def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right)//2
        cnt_L = mergeSort(A, left, mid)
        cnt_R = mergeSort(A, mid, right)
        return merge(A, left, mid, right) + cnt_L + cnt_R
    return 0


res_cnt = mergeSort(num_list, 0, N)
print(*num_list)
print(res_cnt) N = int(input()) N int(input()) int input() input int(item) for item in input().split() for item in input().split() item input().split() ().split () input split for item in input().split() int(item) int item num_list = [int(item) for item in input().split()] num_list [int(item) for item in input().split()] def merge(A, left, mid, right):

    L = A[left : mid] + [100**5]
    R = A[mid: right] + [100**5]
 
    cnt = 0
    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
        # print(A, left, mid, right)
    return cnt merge L = A[left : mid] + [100**5] L A[left : mid] + [100**5] A[left : mid] A left : mid left mid [100**5] 100**5 100 5 R = A[mid: right] + [100**5] R A[mid: right] + [100**5] A[mid: right] A mid: right mid right [100**5] 100**5 100 5 cnt = 0 cnt 0 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
        # print(A, left, mid, right)
     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
        # print(A, left, mid, right)
     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 return cnt cnt A A left left mid mid right right def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right)//2
        cnt_L = mergeSort(A, left, mid)
        cnt_R = mergeSort(A, mid, right)
        return merge(A, left, mid, right) + cnt_L + cnt_R
    return 0 mergeSort if left + 1 < right:
        mid = (left + right)//2
        cnt_L = mergeSort(A, left, mid)
        cnt_R = mergeSort(A, mid, right)
        return merge(A, left, mid, right) + cnt_L + cnt_R
     left + 1 < right left + 1 left 1 right mid = (left + right)//2 mid (left + right)//2 left + right left right 2 cnt_L = mergeSort(A, left, mid) cnt_L mergeSort(A, left, mid) mergeSort A left mid cnt_R = mergeSort(A, mid, right) cnt_R mergeSort(A, mid, right) mergeSort A mid right return merge(A, left, mid, right) + cnt_L + cnt_R merge(A, left, mid, right) + cnt_L + cnt_R merge(A, left, mid, right) + cnt_L merge(A, left, mid, right) merge A left mid right cnt_L cnt_R return 0 0 A A left left right right res_cnt = mergeSort(num_list, 0, N) res_cnt mergeSort(num_list, 0, N) mergeSort num_list 0 N print(*num_list) print *num_list num_list print(res_cnt) print res_cnt N = int(input()) int(input()) N num_list = [int(item) for item in input().split()] [int(item) for item in input().split()] num_list res_cnt = mergeSort(num_list, 0, N) mergeSort(num_list, 0, N) res_cnt def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right)//2
        cnt_L = mergeSort(A, left, mid)
        cnt_R = mergeSort(A, mid, right)
        return merge(A, left, mid, right) + cnt_L + cnt_R
    return 0 def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right)//2
        cnt_L = mergeSort(A, left, mid)
        cnt_R = mergeSort(A, mid, right)
        return merge(A, left, mid, right) + cnt_L + cnt_R
    return 0 mergeSort def merge(A, left, mid, right):

    L = A[left : mid] + [100**5]
    R = A[mid: right] + [100**5]
 
    cnt = 0
    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
        # print(A, left, mid, right)
    return cnt def merge(A, left, mid, right):

    L = A[left : mid] + [100**5]
    R = A[mid: right] + [100**5]
 
    cnt = 0
    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
        # print(A, left, mid, right)
    return cnt merge
N = int(input())
num_list = [int(item) for item in input().split()]


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

    L = A[left : mid] + [100**5]
    R = A[mid: right] + [100**5]
 
    cnt = 0
    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
        # print(A, left, mid, right)
    return cnt


def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right)//2
        cnt_L = mergeSort(A, left, mid)
        cnt_R = mergeSort(A, mid, right)
        return merge(A, left, mid, right) + cnt_L + cnt_R
    return 0


res_cnt = mergeSort(num_list, 0, N)
print(*num_list)
print(res_cnt)
