#C13728. Bubble Sort

    ID: 43298 Type: Default 1000ms 256MiB

Bubble Sort

Bubble Sort

You are given a list of integers. Your task is to implement the Bubble Sort algorithm to sort the list in ascending order. The bubble sort algorithm works by repeatedly swapping adjacent elements if they are in the wrong order. More formally, for any two adjacent elements \(a_j\) and \(a_{j+1}\), if \(a_j > a_{j+1}\), swap them.

Input and Output: Your program should read input from standard input (stdin) and output the sorted list to standard output (stdout).

Example: If the input is 5 followed by the numbers 5 4 3 2 1, the output should be 1 2 3 4 5.

inputFormat

The first line contains a single integer \(n\), representing the number of elements in the list. The second line contains \(n\) space-separated integers.

outputFormat

Output the sorted list of integers in ascending order in one line, with each number separated by a single space.

## sample
5
1 2 3 4 5
1 2 3 4 5