use strict; use warnings; my $n = <>; chomp $n; my $l = <>; chomp $l; my @arr = split/ /,$l; my @res; for (my $i = 0; $i < @arr; $i++) { for (my $j = 0; $j < $i; $j++) { if ($arr[$i] < $arr[$j]) { ($arr[$i], $arr[$j]) = ($arr[$j], $arr[$i]); push @res, [$i, $j]; } } } print scalar(@res) . "\n"; print(join(' ', ($_->[0], $_->[1])) . "\n") for @res; #die 'no more kadomatsu' unless -1 == <>;