import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);

    static void checkArray(int[] a){
        int i ;
        for( i = 0; i < a.length -1; i++){
                System.out.print(a[i] +" ");
        }
        System.out.print(a[i]);
        System.out.println();
    }

    static int[] makeArray(int num){
        int[] arr = new int[num];
        for( int i = 0; i < num; i++){
            arr[i] = sc.nextInt();
        }
        return arr;
    } 

    public static void main(String[] args) {
        int N = sc.nextInt();
        int[] arr = makeArray(N);
       
        int temp;
        int count=0;
        boolean flag = true;
        
        for(int j = 0; flag; j++ ){
            flag = false;
            for(int i = N-1; i >= j+1 ; i--) {
                temp = arr[i];
                if(arr[i] < arr[i-1]) {
                    arr[i] = arr[i-1];
                    arr[i-1] = temp;
                    count++;
                    flag = true;
                }
                
            }
        }
        checkArray(arr);
        System.out.println(count);
    }
    
} import java.util.Scanner; Scanner java.util public class Main {

    static Scanner sc = new Scanner(System.in);

    static void checkArray(int[] a){
        int i ;
        for( i = 0; i < a.length -1; i++){
                System.out.print(a[i] +" ");
        }
        System.out.print(a[i]);
        System.out.println();
    }

    static int[] makeArray(int num){
        int[] arr = new int[num];
        for( int i = 0; i < num; i++){
            arr[i] = sc.nextInt();
        }
        return arr;
    } 

    public static void main(String[] args) {
        int N = sc.nextInt();
        int[] arr = makeArray(N);
       
        int temp;
        int count=0;
        boolean flag = true;
        
        for(int j = 0; flag; j++ ){
            flag = false;
            for(int i = N-1; i >= j+1 ; i--) {
                temp = arr[i];
                if(arr[i] < arr[i-1]) {
                    arr[i] = arr[i-1];
                    arr[i-1] = temp;
                    count++;
                    flag = true;
                }
                
            }
        }
        checkArray(arr);
        System.out.println(count);
    }
    
} Main static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) static void checkArray(int[] a){
        int i ;
        for( i = 0; i < a.length -1; i++){
                System.out.print(a[i] +" ");
        }
        System.out.print(a[i]);
        System.out.println();
    } checkArray {
        int i ;
        for( i = 0; i < a.length -1; i++){
                System.out.print(a[i] +" ");
        }
        System.out.print(a[i]);
        System.out.println();
    } int i ; i for( i = 0; i < a.length -1; i++){
                System.out.print(a[i] +" ");
        } i = 0; i = 0 i 0 i < a.length -1 i a.length -1 a.length a a.length 1 i++ i++ i {
                System.out.print(a[i] +" ");
        } {
                System.out.print(a[i] +" ");
        } System.out.print(a[i] +" ") System.out.print System.out System System.out a[i] +" " a[i] a i " " System.out.print(a[i]) System.out.print System.out System System.out a[i] a i System.out.println() System.out.println System.out System System.out int[] a a static int[] makeArray(int num){
        int[] arr = new int[num];
        for( int i = 0; i < num; i++){
            arr[i] = sc.nextInt();
        }
        return arr;
    } makeArray {
        int[] arr = new int[num];
        for( int i = 0; i < num; i++){
            arr[i] = sc.nextInt();
        }
        return arr;
    } int[] arr = new int[num]; arr new int[num] num for( int i = 0; i < num; i++){
            arr[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < num i num i++ i++ i {
            arr[i] = sc.nextInt();
        } {
            arr[i] = sc.nextInt();
        } arr[i] = sc.nextInt() arr[i] arr i sc.nextInt() sc.nextInt sc return arr; arr int num num public static void main(String[] args) {
        int N = sc.nextInt();
        int[] arr = makeArray(N);
       
        int temp;
        int count=0;
        boolean flag = true;
        
        for(int j = 0; flag; j++ ){
            flag = false;
            for(int i = N-1; i >= j+1 ; i--) {
                temp = arr[i];
                if(arr[i] < arr[i-1]) {
                    arr[i] = arr[i-1];
                    arr[i-1] = temp;
                    count++;
                    flag = true;
                }
                
            }
        }
        checkArray(arr);
        System.out.println(count);
    } main {
        int N = sc.nextInt();
        int[] arr = makeArray(N);
       
        int temp;
        int count=0;
        boolean flag = true;
        
        for(int j = 0; flag; j++ ){
            flag = false;
            for(int i = N-1; i >= j+1 ; i--) {
                temp = arr[i];
                if(arr[i] < arr[i-1]) {
                    arr[i] = arr[i-1];
                    arr[i-1] = temp;
                    count++;
                    flag = true;
                }
                
            }
        }
        checkArray(arr);
        System.out.println(count);
    } int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] arr = makeArray(N); arr makeArray(N) makeArray N int temp; temp int count=0; count 0 boolean flag = true; flag true for(int j = 0; flag; j++ ){
            flag = false;
            for(int i = N-1; i >= j+1 ; i--) {
                temp = arr[i];
                if(arr[i] < arr[i-1]) {
                    arr[i] = arr[i-1];
                    arr[i-1] = temp;
                    count++;
                    flag = true;
                }
                
            }
        } int j = 0; int j = 0; j 0 flag j++ j++ j {
            flag = false;
            for(int i = N-1; i >= j+1 ; i--) {
                temp = arr[i];
                if(arr[i] < arr[i-1]) {
                    arr[i] = arr[i-1];
                    arr[i-1] = temp;
                    count++;
                    flag = true;
                }
                
            }
        } {
            flag = false;
            for(int i = N-1; i >= j+1 ; i--) {
                temp = arr[i];
                if(arr[i] < arr[i-1]) {
                    arr[i] = arr[i-1];
                    arr[i-1] = temp;
                    count++;
                    flag = true;
                }
                
            }
        } flag = false flag false for(int i = N-1; i >= j+1 ; i--) {
                temp = arr[i];
                if(arr[i] < arr[i-1]) {
                    arr[i] = arr[i-1];
                    arr[i-1] = temp;
                    count++;
                    flag = true;
                }
                
            } int i = N-1; int i = N-1; i N-1 N 1 i >= j+1 i j+1 j 1 i-- i-- i {
                temp = arr[i];
                if(arr[i] < arr[i-1]) {
                    arr[i] = arr[i-1];
                    arr[i-1] = temp;
                    count++;
                    flag = true;
                }
                
            } {
                temp = arr[i];
                if(arr[i] < arr[i-1]) {
                    arr[i] = arr[i-1];
                    arr[i-1] = temp;
                    count++;
                    flag = true;
                }
                
            } temp = arr[i] temp arr[i] arr i if(arr[i] < arr[i-1]) {
                    arr[i] = arr[i-1];
                    arr[i-1] = temp;
                    count++;
                    flag = true;
                } arr[i] < arr[i-1] arr[i] arr i arr[i-1] arr i-1 i 1 {
                    arr[i] = arr[i-1];
                    arr[i-1] = temp;
                    count++;
                    flag = true;
                } arr[i] = arr[i-1] arr[i] arr i arr[i-1] arr i-1 i 1 arr[i-1] = temp arr[i-1] arr i-1 i 1 temp count++ count flag = true flag true checkArray(arr) checkArray arr System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

    static Scanner sc = new Scanner(System.in);

    static void checkArray(int[] a){
        int i ;
        for( i = 0; i < a.length -1; i++){
                System.out.print(a[i] +" ");
        }
        System.out.print(a[i]);
        System.out.println();
    }

    static int[] makeArray(int num){
        int[] arr = new int[num];
        for( int i = 0; i < num; i++){
            arr[i] = sc.nextInt();
        }
        return arr;
    } 

    public static void main(String[] args) {
        int N = sc.nextInt();
        int[] arr = makeArray(N);
       
        int temp;
        int count=0;
        boolean flag = true;
        
        for(int j = 0; flag; j++ ){
            flag = false;
            for(int i = N-1; i >= j+1 ; i--) {
                temp = arr[i];
                if(arr[i] < arr[i-1]) {
                    arr[i] = arr[i-1];
                    arr[i-1] = temp;
                    count++;
                    flag = true;
                }
                
            }
        }
        checkArray(arr);
        System.out.println(count);
    }
    
} public class Main {

    static Scanner sc = new Scanner(System.in);

    static void checkArray(int[] a){
        int i ;
        for( i = 0; i < a.length -1; i++){
                System.out.print(a[i] +" ");
        }
        System.out.print(a[i]);
        System.out.println();
    }

    static int[] makeArray(int num){
        int[] arr = new int[num];
        for( int i = 0; i < num; i++){
            arr[i] = sc.nextInt();
        }
        return arr;
    } 

    public static void main(String[] args) {
        int N = sc.nextInt();
        int[] arr = makeArray(N);
       
        int temp;
        int count=0;
        boolean flag = true;
        
        for(int j = 0; flag; j++ ){
            flag = false;
            for(int i = N-1; i >= j+1 ; i--) {
                temp = arr[i];
                if(arr[i] < arr[i-1]) {
                    arr[i] = arr[i-1];
                    arr[i-1] = temp;
                    count++;
                    flag = true;
                }
                
            }
        }
        checkArray(arr);
        System.out.println(count);
    }
    
} Main
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);

    static void checkArray(int[] a){
        int i ;
        for( i = 0; i < a.length -1; i++){
                System.out.print(a[i] +" ");
        }
        System.out.print(a[i]);
        System.out.println();
    }

    static int[] makeArray(int num){
        int[] arr = new int[num];
        for( int i = 0; i < num; i++){
            arr[i] = sc.nextInt();
        }
        return arr;
    } 

    public static void main(String[] args) {
        int N = sc.nextInt();
        int[] arr = makeArray(N);
       
        int temp;
        int count=0;
        boolean flag = true;
        
        for(int j = 0; flag; j++ ){
            flag = false;
            for(int i = N-1; i >= j+1 ; i--) {
                temp = arr[i];
                if(arr[i] < arr[i-1]) {
                    arr[i] = arr[i-1];
                    arr[i-1] = temp;
                    count++;
                    flag = true;
                }
                
            }
        }
        checkArray(arr);
        System.out.println(count);
    }
    
}