Write a program of a Merge Sort algorithm implemented by the following pseudocode. You should also report the number of comparisons in the Merge function.


Merge(A, left, mid, right)
n1 = mid - left;
n2 = right - mid;
create array L[0...n1], R[0...n2]
for i = 0 to n1-1
do L[i] = A[left + i]
for i = 0 to n2-1
do R[i] = A[mid + i]
L[n1] = SENTINEL
R[n2] = SENTINEL
i = 0;
j = 0;
for k = left to right-1
if L[i] <= R[j]
then A[k] = L[i]
i = i + 1
else A[k] = R[j]
j = j + 1

Merge-Sort(A, left, right){
if left+1 < right
then mid = (left + right)/2;
call Merge-Sort(A, left, mid)
call Merge-Sort(A, mid, right)
call Merge(A, left, mid, right)


Notes

Constraints

* n ≤ 500000
* 0 ≤ an element in S ≤ 109

Input

In the first line n is given. In the second line, n integers are given.

Output

In the first line, print the sequence S. Two consequtive elements should be separated by a space character.

In the second line, print the number of comparisons.

Example

Input

10
8 5 9 2 6 3 7 1 10 4


Output

1 2 3 4 5 6 7 8 9 10
34
public class Main{
  static int infi = 1000000001;
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n;
    int[] a;
    int i, count;

    n = sc.nextInt();
    a = new int[n];
    for(i = 0;i < n;i++)a[i] = sc.nextInt();

    count = mergesort(a, 0, n);
    for(i = 0;i < n - 1;i++)System.out.print(a[i] + " ");
    System.out.println(a[i]);
    System.out.println(count);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }

  private static int mergesort(int[] a, int l, int r){
    int m, c;
    if(l + 1 >= r)return 0;
    else{
      m = (l + r) / 2;
      c = mergesort(a, l, m);
      c += mergesort(a, m, r);
      c += merge(a, l, m, r);
      return c;
    }
  }

  private static int merge(int[] a, int l, int m, int r){
    int nl, nr, count;
    int i, j, k;
    int[] al, ar;

    nl = m - l;
    nr = r - m;
    al = new int[nl + 1];
    ar = new int[nr + 1];
    for(i = 0;i < nl;i++)al[i] = a[l + i];
    for(i = 0;i < nr;i++)ar[i] = a[m + i];
    al[nl] = infi;
    ar[nr] = infi;

    i = 0;j = 0;count = 0;

    for(k = l;k < r;k++){
      if(al[i] <= ar[j]){
        a[k] = al[i++];
        count++;
      }else{
        a[k] = ar[j++];
        count++;
      }
    }

    return count;

  }
}