import std.algorithm, std.array, std.container, std.range; import std.string, std.conv, std.math; import std.stdio, std.typecons; void main() { auto d = readln.chomp.to!int; auto ai = readln.split.map!(to!int).array; ai.reverse(); while (ai.length > 3) { auto a = ai.front; ai[0] -= a; ai[2] += a; ai = ai.find!("a != 0"); } if (ai.empty) { writeln(0); writeln(0); } else { ai.reverse(); writeln(ai.length - 1); writeln(ai.map!(to!string).join(" ")); } }