public class
Main
{
  private int swc;

  private void
  sort (
    int[ ] a
    )
  {
    int i, j;

    for ( i = 0; i < a.length; ++i )
    {
      for ( j = 1; j < a.length - i; ++j )
      {
        if ( a[ j ] < a[ j - 1 ] )
          swap ( a, j - 1, j );
      }
    }
  }
  
  private void
  swap (
    int[ ] a,
    int    i,
    int    j
    )
  {
    final int t = a[ i ];
    a[ i ] = a[ j ];
    a[ j ] = t;
    ++swc;
  }

  private void
  printArray (
    int[ ] a
    )
  {
    int i;

    for ( i = 0; i < a.length; ++i )
    {
      System.out.print ( a[ i ] );
      if ( i + 1 < a.length )
        System.out.print ( " " );
      else
        System.out.println ( );
    }
  }

  public void
  run (
    java.util.Scanner sc
    )
  {
    int[ ] a;
    int i, j;

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

    swc = 0;
    sort ( a );
    printArray ( a );
    System.out.println ( swc );
  }

  public static void
  main (
    String[ ] args
    )
  {
    ( new Main ( ) ).run ( new java.util.Scanner ( System.in ) );
  }
} Main
{
  private int swc;

  private void
  sort (
    int[ ] a
    )
  {
    int i, j;

    for ( i = 0; i < a.length; ++i )
    {
      for ( j = 1; j < a.length - i; ++j )
      {
        if ( a[ j ] < a[ j - 1 ] )
          swap ( a, j - 1, j );
      }
    }
  }
  
  private void
  swap (
    int[ ] a,
    int    i,
    int    j
    )
  {
    final int t = a[ i ];
    a[ i ] = a[ j ];
    a[ j ] = t;
    ++swc;
  }

  private void
  printArray (
    int[ ] a
    )
  {
    int i;

    for ( i = 0; i < a.length; ++i )
    {
      System.out.print ( a[ i ] );
      if ( i + 1 < a.length )
        System.out.print ( " " );
      else
        System.out.println ( );
    }
  }

  public void
  run (
    java.util.Scanner sc
    )
  {
    int[ ] a;
    int i, j;

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

    swc = 0;
    sort ( a );
    printArray ( a );
    System.out.println ( swc );
  }

  public static void
  main (
    String[ ] args
    )
  {
    ( new Main ( ) ).run ( new java.util.Scanner ( System.in ) );
  }
} Main private int swc; swc private void
  sort (
    int[ ] a
    )
  {
    int i, j;

    for ( i = 0; i < a.length; ++i )
    {
      for ( j = 1; j < a.length - i; ++j )
      {
        if ( a[ j ] < a[ j - 1 ] )
          swap ( a, j - 1, j );
      }
    }
  } sort {
    int i, j;

    for ( i = 0; i < a.length; ++i )
    {
      for ( j = 1; j < a.length - i; ++j )
      {
        if ( a[ j ] < a[ j - 1 ] )
          swap ( a, j - 1, j );
      }
    }
  } int i i j; j for ( i = 0; i < a.length; ++i )
    {
      for ( j = 1; j < a.length - i; ++j )
      {
        if ( a[ j ] < a[ j - 1 ] )
          swap ( a, j - 1, j );
      }
    } i = 0; i = 0 i 0 i < a.length i a.length a a.length ++i ++i i {
      for ( j = 1; j < a.length - i; ++j )
      {
        if ( a[ j ] < a[ j - 1 ] )
          swap ( a, j - 1, j );
      }
    } {
      for ( j = 1; j < a.length - i; ++j )
      {
        if ( a[ j ] < a[ j - 1 ] )
          swap ( a, j - 1, j );
      }
    } for ( j = 1; j < a.length - i; ++j )
      {
        if ( a[ j ] < a[ j - 1 ] )
          swap ( a, j - 1, j );
      } j = 1; j = 1 j 1 j < a.length - i j a.length - i a.length a a.length i ++j ++j j {
        if ( a[ j ] < a[ j - 1 ] )
          swap ( a, j - 1, j );
      } {
        if ( a[ j ] < a[ j - 1 ] )
          swap ( a, j - 1, j );
      } if ( a[ j ] < a[ j - 1 ] )
          swap ( a, j - 1, j ); a[ j ] < a[ j - 1 ] a[ j ] a j a[ j - 1 ] a j - 1 j 1 swap ( a, j - 1, j ) swap a j - 1 j 1 j int[ ] a a private void
  swap (
    int[ ] a,
    int    i,
    int    j
    )
  {
    final int t = a[ i ];
    a[ i ] = a[ j ];
    a[ j ] = t;
    ++swc;
  } swap {
    final int t = a[ i ];
    a[ i ] = a[ j ];
    a[ j ] = t;
    ++swc;
  } final int t = a[ i ]; t a[ i ] a i a[ i ] = a[ j ] a[ i ] a i a[ j ] a j a[ j ] = t a[ j ] a j t ++swc swc int[ ] a a int    i i int    j j private void
  printArray (
    int[ ] a
    )
  {
    int i;

    for ( i = 0; i < a.length; ++i )
    {
      System.out.print ( a[ i ] );
      if ( i + 1 < a.length )
        System.out.print ( " " );
      else
        System.out.println ( );
    }
  } printArray {
    int i;

    for ( i = 0; i < a.length; ++i )
    {
      System.out.print ( a[ i ] );
      if ( i + 1 < a.length )
        System.out.print ( " " );
      else
        System.out.println ( );
    }
  } int i; i for ( i = 0; i < a.length; ++i )
    {
      System.out.print ( a[ i ] );
      if ( i + 1 < a.length )
        System.out.print ( " " );
      else
        System.out.println ( );
    } i = 0; i = 0 i 0 i < a.length i a.length a a.length ++i ++i i {
      System.out.print ( a[ i ] );
      if ( i + 1 < a.length )
        System.out.print ( " " );
      else
        System.out.println ( );
    } {
      System.out.print ( a[ i ] );
      if ( i + 1 < a.length )
        System.out.print ( " " );
      else
        System.out.println ( );
    } System.out.print ( a[ i ] ) System.out.print System.out System System.out a[ i ] a i if ( i + 1 < a.length )
        System.out.print ( " " );
      else
        System.out.println ( ); i + 1 < a.length i + 1 i 1 a.length a a.length System.out.print ( " " ) System.out.print System.out System System.out " " System.out.println ( ) System.out.println System.out System System.out int[ ] a a public void
  run (
    java.util.Scanner sc
    )
  {
    int[ ] a;
    int i, j;

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

    swc = 0;
    sort ( a );
    printArray ( a );
    System.out.println ( swc );
  } run {
    int[ ] a;
    int i, j;

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

    swc = 0;
    sort ( a );
    printArray ( a );
    System.out.println ( swc );
  } int[ ] a; a int i i j; j a = new int[ sc.nextInt ( ) ] a new int[ sc.nextInt ( ) ] sc.nextInt ( ) sc.nextInt sc for ( i = 0; i < a.length; ++i )
      a[ i ] = sc.nextInt ( ); i = 0; i = 0 i 0 i < a.length i a.length a a.length ++i ++i i a[ i ] = sc.nextInt ( ); a[ i ] = sc.nextInt ( ) a[ i ] a i sc.nextInt ( ) sc.nextInt sc swc = 0 swc 0 sort ( a ) sort a printArray ( a ) printArray a System.out.println ( swc ) System.out.println System.out System System.out swc java.util.Scanner sc sc public static void
  main (
    String[ ] args
    )
  {
    ( new Main ( ) ).run ( new java.util.Scanner ( System.in ) );
  } main {
    ( new Main ( ) ).run ( new java.util.Scanner ( System.in ) );
  } ( new Main ( ) ).run ( new java.util.Scanner ( System.in ) ) ( new Main ( ) ).run ( new Main ( ) ) new java.util.Scanner ( System.in ) String[ ] args args Main
{
  private int swc;

  private void
  sort (
    int[ ] a
    )
  {
    int i, j;

    for ( i = 0; i < a.length; ++i )
    {
      for ( j = 1; j < a.length - i; ++j )
      {
        if ( a[ j ] < a[ j - 1 ] )
          swap ( a, j - 1, j );
      }
    }
  }
  
  private void
  swap (
    int[ ] a,
    int    i,
    int    j
    )
  {
    final int t = a[ i ];
    a[ i ] = a[ j ];
    a[ j ] = t;
    ++swc;
  }

  private void
  printArray (
    int[ ] a
    )
  {
    int i;

    for ( i = 0; i < a.length; ++i )
    {
      System.out.print ( a[ i ] );
      if ( i + 1 < a.length )
        System.out.print ( " " );
      else
        System.out.println ( );
    }
  }

  public void
  run (
    java.util.Scanner sc
    )
  {
    int[ ] a;
    int i, j;

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

    swc = 0;
    sort ( a );
    printArray ( a );
    System.out.println ( swc );
  }

  public static void
  main (
    String[ ] args
    )
  {
    ( new Main ( ) ).run ( new java.util.Scanner ( System.in ) );
  }
} Main
{
  private int swc;

  private void
  sort (
    int[ ] a
    )
  {
    int i, j;

    for ( i = 0; i < a.length; ++i )
    {
      for ( j = 1; j < a.length - i; ++j )
      {
        if ( a[ j ] < a[ j - 1 ] )
          swap ( a, j - 1, j );
      }
    }
  }
  
  private void
  swap (
    int[ ] a,
    int    i,
    int    j
    )
  {
    final int t = a[ i ];
    a[ i ] = a[ j ];
    a[ j ] = t;
    ++swc;
  }

  private void
  printArray (
    int[ ] a
    )
  {
    int i;

    for ( i = 0; i < a.length; ++i )
    {
      System.out.print ( a[ i ] );
      if ( i + 1 < a.length )
        System.out.print ( " " );
      else
        System.out.println ( );
    }
  }

  public void
  run (
    java.util.Scanner sc
    )
  {
    int[ ] a;
    int i, j;

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

    swc = 0;
    sort ( a );
    printArray ( a );
    System.out.println ( swc );
  }

  public static void
  main (
    String[ ] args
    )
  {
    ( new Main ( ) ).run ( new java.util.Scanner ( System.in ) );
  }
} Main
public class
Main
{
  private int swc;

  private void
  sort (
    int[ ] a
    )
  {
    int i, j;

    for ( i = 0; i < a.length; ++i )
    {
      for ( j = 1; j < a.length - i; ++j )
      {
        if ( a[ j ] < a[ j - 1 ] )
          swap ( a, j - 1, j );
      }
    }
  }
  
  private void
  swap (
    int[ ] a,
    int    i,
    int    j
    )
  {
    final int t = a[ i ];
    a[ i ] = a[ j ];
    a[ j ] = t;
    ++swc;
  }

  private void
  printArray (
    int[ ] a
    )
  {
    int i;

    for ( i = 0; i < a.length; ++i )
    {
      System.out.print ( a[ i ] );
      if ( i + 1 < a.length )
        System.out.print ( " " );
      else
        System.out.println ( );
    }
  }

  public void
  run (
    java.util.Scanner sc
    )
  {
    int[ ] a;
    int i, j;

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

    swc = 0;
    sort ( a );
    printArray ( a );
    System.out.println ( swc );
  }

  public static void
  main (
    String[ ] args
    )
  {
    ( new Main ( ) ).run ( new java.util.Scanner ( System.in ) );
  }
}