global_count = 0

def sort(a):
    return merge_sort(a)

def merge_sort(a):
    n = len(a)
    if n <= 1:
        return a
    lo = 0
    hi = n
    med = (lo+hi)/2
    left = merge_sort(a[lo:med])
    right = merge_sort(a[med:hi])
    return merge(left, right)

def merge(a,b):
    global global_count
    c = []
    na = len(a)
    nb = len(b)
    i = 0
    j = 0
    while i < na and j < nb:
        if a[i] < b[j]:
            global_count += 1
            c.append(a[i])
            i += 1
        else:
            global_count += 1
            c.append(b[j])
            j += 1

    if i == na:
        while j < nb:
            global_count += 1
            c.append(b[j])
            j += 1
    if j == nb:
        while i < na:
            global_count += 1
            c.append(a[i])
            i += 1

    return c

n = int(raw_input())
a = map(int, raw_input().split(' '))
c = sort(a)
print ' '.join(map(str, c))
print global_count global_count = 0 global_count 0 def sort(a):
    return merge_sort(a) sort return merge_sort(a) merge_sort(a) merge_sort a a a def merge_sort(a):
    n = len(a)
    if n <= 1:
        return a
    lo = 0
    hi = n
    med = (lo+hi)/2
    left = merge_sort(a[lo:med])
    right = merge_sort(a[med:hi])
    return merge(left, right) merge_sort n = len(a) n len(a) len a if n <= 1:
        return a
     n <= 1 n 1 return a a lo = 0 lo 0 hi = n hi n med = (lo+hi)/2 med (lo+hi)/2 lo+hi lo hi 2 left = merge_sort(a[lo:med]) left merge_sort(a[lo:med]) merge_sort a[lo:med] a lo:med lo med right = merge_sort(a[med:hi]) right merge_sort(a[med:hi]) merge_sort a[med:hi] a med:hi med hi return merge(left, right) merge(left, right) merge left right a a def merge(a,b):
    global global_count
    c = []
    na = len(a)
    nb = len(b)
    i = 0
    j = 0
    while i < na and j < nb:
        if a[i] < b[j]:
            global_count += 1
            c.append(a[i])
            i += 1
        else:
            global_count += 1
            c.append(b[j])
            j += 1

    if i == na:
        while j < nb:
            global_count += 1
            c.append(b[j])
            j += 1
    if j == nb:
        while i < na:
            global_count += 1
            c.append(a[i])
            i += 1

    return c merge global global_count c = [] c [] na = len(a) na len(a) len a nb = len(b) nb len(b) len b i = 0 i 0 j = 0 j 0 while i < na and j < nb:
        if a[i] < b[j]:
            global_count += 1
            c.append(a[i])
            i += 1
        else:
            global_count += 1
            c.append(b[j])
            j += 1

     i < na and j < nb i < na i na j < nb j nb if a[i] < b[j]:
            global_count += 1
            c.append(a[i])
            i += 1
        else:
            global_count += 1
            c.append(b[j])
            j += 1

     a[i] < b[j] a[i] a i b[j] b j global_count += 1 global_count 1 c.append(a[i]) c.append c append a[i] a i i += 1 i 1 global_count += 1 global_count 1 c.append(b[j]) c.append c append b[j] b j j += 1 j 1 if i == na:
        while j < nb:
            global_count += 1
            c.append(b[j])
            j += 1
     i == na i na while j < nb:
            global_count += 1
            c.append(b[j])
            j += 1
     j < nb j nb global_count += 1 global_count 1 c.append(b[j]) c.append c append b[j] b j j += 1 j 1 if j == nb:
        while i < na:
            global_count += 1
            c.append(a[i])
            i += 1

     j == nb j nb while i < na:
            global_count += 1
            c.append(a[i])
            i += 1

     i < na i na global_count += 1 global_count 1 c.append(a[i]) c.append c append a[i] a i i += 1 i 1 return c c a a b b n = int(raw_input()) n int(raw_input()) int raw_input() raw_input a = map(int, raw_input().split(' ')) a map(int, raw_input().split(' ')) map int raw_input().split(' ') ().split () raw_input split ' ' c = sort(a) c sort(a) sort a print ' '.join(map(str, c)) ' '.join ' ' join map(str, c) map str c print c = sort(a) sort(a) c a = map(int, raw_input().split(' ')) map(int, raw_input().split(' ')) a global_count = 0 0 global_count def merge_sort(a):
    n = len(a)
    if n <= 1:
        return a
    lo = 0
    hi = n
    med = (lo+hi)/2
    left = merge_sort(a[lo:med])
    right = merge_sort(a[med:hi])
    return merge(left, right) def merge_sort(a):
    n = len(a)
    if n <= 1:
        return a
    lo = 0
    hi = n
    med = (lo+hi)/2
    left = merge_sort(a[lo:med])
    right = merge_sort(a[med:hi])
    return merge(left, right) merge_sort n = int(raw_input()) int(raw_input()) n def sort(a):
    return merge_sort(a) def sort(a):
    return merge_sort(a) sort def merge(a,b):
    global global_count
    c = []
    na = len(a)
    nb = len(b)
    i = 0
    j = 0
    while i < na and j < nb:
        if a[i] < b[j]:
            global_count += 1
            c.append(a[i])
            i += 1
        else:
            global_count += 1
            c.append(b[j])
            j += 1

    if i == na:
        while j < nb:
            global_count += 1
            c.append(b[j])
            j += 1
    if j == nb:
        while i < na:
            global_count += 1
            c.append(a[i])
            i += 1

    return c def merge(a,b):
    global global_count
    c = []
    na = len(a)
    nb = len(b)
    i = 0
    j = 0
    while i < na and j < nb:
        if a[i] < b[j]:
            global_count += 1
            c.append(a[i])
            i += 1
        else:
            global_count += 1
            c.append(b[j])
            j += 1

    if i == na:
        while j < nb:
            global_count += 1
            c.append(b[j])
            j += 1
    if j == nb:
        while i < na:
            global_count += 1
            c.append(a[i])
            i += 1

    return c merge
global_count = 0

def sort(a):
    return merge_sort(a)

def merge_sort(a):
    n = len(a)
    if n <= 1:
        return a
    lo = 0
    hi = n
    med = (lo+hi)/2
    left = merge_sort(a[lo:med])
    right = merge_sort(a[med:hi])
    return merge(left, right)

def merge(a,b):
    global global_count
    c = []
    na = len(a)
    nb = len(b)
    i = 0
    j = 0
    while i < na and j < nb:
        if a[i] < b[j]:
            global_count += 1
            c.append(a[i])
            i += 1
        else:
            global_count += 1
            c.append(b[j])
            j += 1

    if i == na:
        while j < nb:
            global_count += 1
            c.append(b[j])
            j += 1
    if j == nb:
        while i < na:
            global_count += 1
            c.append(a[i])
            i += 1

    return c

n = int(raw_input())
a = map(int, raw_input().split(' '))
c = sort(a)
print ' '.join(map(str, c))
print global_count