n = read_line.to_i a = read_line.split.map(&.to_i) v = (0...n).to_a.sort_by { |i| a[i] } v += v pos = v.index(0).not_nil! puts (v[pos, n].map { |v| v + 1 } + [1]).join(" ")