N = gets.to_i A = gets.split.map(&:to_i) O = (0 ... N).sort_by{|i| A[i] } used = Array.new(N) T = N.times.map do |i| if O[i] != i && A[O[i]] != A[i] && !used[i] used[i] = used[O[i]] = true "#{i} #{O[i]}" else nil end end T.compact! puts T $stdout.flush gets exit(0)