import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, core.stdc.stdio; void main() { auto N = readln.chomp.to!int; auto A = readln.split.map!(to!int).array; int[] solve() { int[][] B; int tmp = 1 << 29; foreach (a; A) { if (a > tmp) { B.back ~= a; tmp = a; } else { B ~= [a]; tmp = a; } } if (B.length > 1 && B[0..$-1].map!(b => b.front > B.back.back).any) { return []; } int[] ans; foreach (i; 0..B.length.to!int-1) { foreach (j; 1..B[i].length) { ans ~= B[i][j]; } } foreach_reverse (i; 0..B.back.length.to!int-1) { ans ~= B.back[i]; } foreach_reverse (i; 0..B.length.to!int-1) { ans ~= B[i].front; } return ans; } auto ans = solve; if (ans.length > 0) { writeln("Yes"); ans.map!(to!string).join(" ").writeln; return; } foreach (i; 0..N/2) { swap(A[i], A[N-i-1]); } foreach (i; 0..N) { A[i] *= -1; } ans = solve; if (ans.length > 0) { writeln("Yes"); ans.map!(a => -a).map!(to!string).join(" ").writeln; } else { writeln("No"); } }