#!/usr/bin/python
# -*- coding: UTF-8 -*-

# Author: Seowon Jung
# Class: CSCI 3101
# Homework-3


def RecursiveInsertionSort(A, n):
	if n > 0:
		RecursiveInsertionSort(A, n-1)

		if not n == len(A):
			Insert(A, n)

	return A


def Insert(A, n):
	key = A[n]
	i = n-1

	while (i >= 0 and A[i] > key):
		A[i+1] = A[i]
		i -= 1

	A[i+1] = key
	return A

	
A = [8, 2, 5, 9, 1, 4, 3, 7, 6]	
sortedArray = RecursiveInsertionSort(A, len(A))

print sortedArray