699. Sort Linked List

0

Easy

Given a linked list with n nodes, the task is to sort the linked list using the insertion sort algorithm.

Input Format

The input consists of two lines. The first line contains an integer n, representing the number of nodes in the linked list. The second line contains n space-separated integers, representing the node values of the linked list.

Output Format

Print the linked list after sorting it using the insertion sort algorithm.

Example

Input

5
2 3 4 1 5

Output

1 2 3 4 5

Constraints

n must be less than 30

Loading...

View Submissions

Console