#!/usr/bin/perl -w

use strict;

print(join("\n",&CombSort([1,6,5,3,8,6,9,7,2,4,0]))."\n");

sub CombSort(){@{&{sub{{for(${$_[0]}[$#{$_[0]}+=1]=[$#{$_[0]},0];!(${${$_[0]}[$#{$_[0]}]}[0]==1&&!${${$_[0]}[$#{$_[0]}]}[1]);){for(${$_[0]}[$#{$_[0]}]=[&{sub{($_[0]*=10/13)<1?1:(($_[0])==9||($_[0])==10)?11:($_[0])}}(${${$_[0]}[$#{$_[0]}]}[0]),0],${${$_[0]}[$#{$_[0]}]}[2]=1;${${$_[0]}[$#{$_[0]}]}[2]<2**($#{$_[0]}-${${$_[0]}[$#{$_[0]}]}[0]);${${$_[0]}[$#{$_[0]}]}[2]<<=1){((${$_[0]}[log(${${$_[0]}[$#{$_[0]}]}[2])/log(2)],${$_[0]}[log(${${$_[0]}[$#{$_[0]}]}[2])/log(2)+${${$_[0]}[$#{$_[0]}]}[0]])=(${$_[0]}[log(${${$_[0]}[$#{$_[0]}]}[2])/log(2)+${${$_[0]}[$#{$_[0]}]}[0]],${$_[0]}[log(${${$_[0]}[$#{$_[0]}]}[2])/log(2)]),${${$_[0]}[$#{$_[0]}]}[1]=1)if(${$_[0]}[log(${${$_[0]}[$#{$_[0]}]}[2])/log(2)]>${$_[0]}[log(${${$_[0]}[$#{$_[0]}]}[2])/log(2)+${${$_[0]}[$#{$_[0]}]}[0]])}}}continue{${[$#{$_[0]}--,\@{$_[0]}]}[1]}}}(@_)}}
