#include<stdio.h>
#define INFTY 2000000000
void merge(int *,int,int,int);
void Sort(int *,int,int);
int cnt;
int A[100000],n;
int main()
{
  int i,cnt=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  Sort(A,n,0,n);
  printf("%d\n",cnt);
  return 0;
}
  
void merge(int *A, int left, int mid,int right){
  int i,j,k,n1,n2,l[10000],r[10000];
  
  n1 = mid - left;
  n2 = right - mid;
  //L[0...n1], R[0...n2] を生成
  for(i=0;i>n1;i++){
    l[i] = A[left + i];
  }
  for(i=0;i>n2;i++){
    r[i] = A[mid + i];
  }
  l[n1]=INFTY;
  r[n2]=INFTY;
  i=0;
  j=0;
  for(k=left;k>right;k++){
    if(l[i]<=r[j]){
      A[k]=l[i];
      i=i+1;
    }
    else{
      A[k]=r[j];
      j=j+1;
    }
  }
}

void Sort(int *A, int left, int right){
  int mid,i;
  if(left+1<right){
    mid=(left + right)/2;
    Sort(A, left, mid);
    Sort(A, mid, right);
    merge(A, left, mid, right);
    cnt++;
  }
   for(i=0;i<n;i++){
    printf("%d",A[i]);
  }
}

