import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
//		System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		int times = scan.nextInt();
		int num[] =new int[times];
		int temp = 0; 
		int finir = -1;
		int irekae = 0;
		int i = 0;
		for(i=0;i<times;i++){
			num[i] = scan.nextInt();
		}
		i = 0;
		int bot = num.length-1;
		int pre = bot-1;
		while (times != 1){
			if(num[pre - i] > num[bot -i]){//???????°?2????????????????°?????????\????????????
//				System.out.println("irekae"+num[pre-i]+" "+num[bot-i]);
				temp = num[bot-i];
				num[bot-i] = num[pre-i];
				num[pre-i] = temp;
				irekae += 1;
			}
			
			i += 1;
			
			if(finir == pre-i){//???-1????????????????????\?????????????°??????????
				finir += 1;
//				System.out.println("finir "+finir);
				if(finir == num.length-2){
					break;
				}
				i = 0;
			}
		}
		for(i=0;i<times;i++){
			System.out.print(num[i]);
			if(i == times-1){
				System.out.println("");
				System.out.println(irekae);
			}
			else{
				System.out.print(" ");
			}
			
		}
	}
} import java.io.IOException; IOException java.io import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
//		System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		int times = scan.nextInt();
		int num[] =new int[times];
		int temp = 0; 
		int finir = -1;
		int irekae = 0;
		int i = 0;
		for(i=0;i<times;i++){
			num[i] = scan.nextInt();
		}
		i = 0;
		int bot = num.length-1;
		int pre = bot-1;
		while (times != 1){
			if(num[pre - i] > num[bot -i]){//???????°?2????????????????°?????????\????????????
//				System.out.println("irekae"+num[pre-i]+" "+num[bot-i]);
				temp = num[bot-i];
				num[bot-i] = num[pre-i];
				num[pre-i] = temp;
				irekae += 1;
			}
			
			i += 1;
			
			if(finir == pre-i){//???-1????????????????????\?????????????°??????????
				finir += 1;
//				System.out.println("finir "+finir);
				if(finir == num.length-2){
					break;
				}
				i = 0;
			}
		}
		for(i=0;i<times;i++){
			System.out.print(num[i]);
			if(i == times-1){
				System.out.println("");
				System.out.println(irekae);
			}
			else{
				System.out.print(" ");
			}
			
		}
	}
} Main public static void main(String[] args)throws NumberFormatException, IOException{
//		System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		int times = scan.nextInt();
		int num[] =new int[times];
		int temp = 0; 
		int finir = -1;
		int irekae = 0;
		int i = 0;
		for(i=0;i<times;i++){
			num[i] = scan.nextInt();
		}
		i = 0;
		int bot = num.length-1;
		int pre = bot-1;
		while (times != 1){
			if(num[pre - i] > num[bot -i]){//???????°?2????????????????°?????????\????????????
//				System.out.println("irekae"+num[pre-i]+" "+num[bot-i]);
				temp = num[bot-i];
				num[bot-i] = num[pre-i];
				num[pre-i] = temp;
				irekae += 1;
			}
			
			i += 1;
			
			if(finir == pre-i){//???-1????????????????????\?????????????°??????????
				finir += 1;
//				System.out.println("finir "+finir);
				if(finir == num.length-2){
					break;
				}
				i = 0;
			}
		}
		for(i=0;i<times;i++){
			System.out.print(num[i]);
			if(i == times-1){
				System.out.println("");
				System.out.println(irekae);
			}
			else{
				System.out.print(" ");
			}
			
		}
	} main {
//		System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		int times = scan.nextInt();
		int num[] =new int[times];
		int temp = 0; 
		int finir = -1;
		int irekae = 0;
		int i = 0;
		for(i=0;i<times;i++){
			num[i] = scan.nextInt();
		}
		i = 0;
		int bot = num.length-1;
		int pre = bot-1;
		while (times != 1){
			if(num[pre - i] > num[bot -i]){//???????°?2????????????????°?????????\????????????
//				System.out.println("irekae"+num[pre-i]+" "+num[bot-i]);
				temp = num[bot-i];
				num[bot-i] = num[pre-i];
				num[pre-i] = temp;
				irekae += 1;
			}
			
			i += 1;
			
			if(finir == pre-i){//???-1????????????????????\?????????????°??????????
				finir += 1;
//				System.out.println("finir "+finir);
				if(finir == num.length-2){
					break;
				}
				i = 0;
			}
		}
		for(i=0;i<times;i++){
			System.out.print(num[i]);
			if(i == times-1){
				System.out.println("");
				System.out.println(irekae);
			}
			else{
				System.out.print(" ");
			}
			
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int times = scan.nextInt(); times scan.nextInt() scan.nextInt scan int num[] =new int[times]; num new int[times] times int temp = 0; temp 0 int finir = -1; finir -1 1 int irekae = 0; irekae 0 int i = 0; i 0 for(i=0;i<times;i++){
			num[i] = scan.nextInt();
		} i=0; i=0 i 0 i<times i times i++ i++ i {
			num[i] = scan.nextInt();
		} {
			num[i] = scan.nextInt();
		} num[i] = scan.nextInt() num[i] num i scan.nextInt() scan.nextInt scan i = 0 i 0 int bot = num.length-1; bot num.length-1 num.length num num.length 1 int pre = bot-1; pre bot-1 bot 1 while (times != 1){
			if(num[pre - i] > num[bot -i]){//???????°?2????????????????°?????????\????????????
//				System.out.println("irekae"+num[pre-i]+" "+num[bot-i]);
				temp = num[bot-i];
				num[bot-i] = num[pre-i];
				num[pre-i] = temp;
				irekae += 1;
			}
			
			i += 1;
			
			if(finir == pre-i){//???-1????????????????????\?????????????°??????????
				finir += 1;
//				System.out.println("finir "+finir);
				if(finir == num.length-2){
					break;
				}
				i = 0;
			}
		} times != 1 times 1 {
			if(num[pre - i] > num[bot -i]){//???????°?2????????????????°?????????\????????????
//				System.out.println("irekae"+num[pre-i]+" "+num[bot-i]);
				temp = num[bot-i];
				num[bot-i] = num[pre-i];
				num[pre-i] = temp;
				irekae += 1;
			}
			
			i += 1;
			
			if(finir == pre-i){//???-1????????????????????\?????????????°??????????
				finir += 1;
//				System.out.println("finir "+finir);
				if(finir == num.length-2){
					break;
				}
				i = 0;
			}
		} if(num[pre - i] > num[bot -i]){//???????°?2????????????????°?????????\????????????
//				System.out.println("irekae"+num[pre-i]+" "+num[bot-i]);
				temp = num[bot-i];
				num[bot-i] = num[pre-i];
				num[pre-i] = temp;
				irekae += 1;
			} num[pre - i] > num[bot -i] num[pre - i] num pre - i pre i num[bot -i] num bot -i bot i {//???????°?2????????????????°?????????\????????????
//				System.out.println("irekae"+num[pre-i]+" "+num[bot-i]);
				temp = num[bot-i];
				num[bot-i] = num[pre-i];
				num[pre-i] = temp;
				irekae += 1;
			} temp = num[bot-i] temp num[bot-i] num bot-i bot i num[bot-i] = num[pre-i] num[bot-i] num bot-i bot i num[pre-i] num pre-i pre i num[pre-i] = temp num[pre-i] num pre-i pre i temp irekae += 1 irekae 1 i += 1 i 1 if(finir == pre-i){//???-1????????????????????\?????????????°??????????
				finir += 1;
//				System.out.println("finir "+finir);
				if(finir == num.length-2){
					break;
				}
				i = 0;
			} finir == pre-i finir pre-i pre i {//???-1????????????????????\?????????????°??????????
				finir += 1;
//				System.out.println("finir "+finir);
				if(finir == num.length-2){
					break;
				}
				i = 0;
			} finir += 1 finir 1 if(finir == num.length-2){
					break;
				} finir == num.length-2 finir num.length-2 num.length num num.length 2 {
					break;
				} break; i = 0 i 0 for(i=0;i<times;i++){
			System.out.print(num[i]);
			if(i == times-1){
				System.out.println("");
				System.out.println(irekae);
			}
			else{
				System.out.print(" ");
			}
			
		} i=0; i=0 i 0 i<times i times i++ i++ i {
			System.out.print(num[i]);
			if(i == times-1){
				System.out.println("");
				System.out.println(irekae);
			}
			else{
				System.out.print(" ");
			}
			
		} {
			System.out.print(num[i]);
			if(i == times-1){
				System.out.println("");
				System.out.println(irekae);
			}
			else{
				System.out.print(" ");
			}
			
		} System.out.print(num[i]) System.out.print System.out System System.out num[i] num i if(i == times-1){
				System.out.println("");
				System.out.println(irekae);
			}
			else{
				System.out.print(" ");
			} i == times-1 i times-1 times 1 {
				System.out.println("");
				System.out.println(irekae);
			} System.out.println("") System.out.println System.out System System.out "" System.out.println(irekae) System.out.println System.out System System.out irekae {
				System.out.print(" ");
			} System.out.print(" ") System.out.print System.out System System.out " " String[] args args
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
//		System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		int times = scan.nextInt();
		int num[] =new int[times];
		int temp = 0; 
		int finir = -1;
		int irekae = 0;
		int i = 0;
		for(i=0;i<times;i++){
			num[i] = scan.nextInt();
		}
		i = 0;
		int bot = num.length-1;
		int pre = bot-1;
		while (times != 1){
			if(num[pre - i] > num[bot -i]){//???????°?2????????????????°?????????\????????????
//				System.out.println("irekae"+num[pre-i]+" "+num[bot-i]);
				temp = num[bot-i];
				num[bot-i] = num[pre-i];
				num[pre-i] = temp;
				irekae += 1;
			}
			
			i += 1;
			
			if(finir == pre-i){//???-1????????????????????\?????????????°??????????
				finir += 1;
//				System.out.println("finir "+finir);
				if(finir == num.length-2){
					break;
				}
				i = 0;
			}
		}
		for(i=0;i<times;i++){
			System.out.print(num[i]);
			if(i == times-1){
				System.out.println("");
				System.out.println(irekae);
			}
			else{
				System.out.print(" ");
			}
			
		}
	}
}