#include // clang-format off using Int = long long; #define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++) #define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__) struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io; #ifndef _MY_DEBUG #define dump(...) #endif // clang-format on /** * author: knshnb * created: Mon Apr 6 17:27:48 JST 2020 **/ template T make_vec(S x) { return x; } template auto make_vec(size_t n, Ts... ts) { return std::vector(ts...))>(n, make_vec(ts...)); } const Int K = 18; const Int S = 18 * 150000 / 2; signed main() { Int n; std::cin >> n; std::vector a(n); REP(i, n) std::cin >> a[i]; Int m = std::min(n, K); auto dp = make_vec(m + 1, 2 * S + 1, 0); dp[0][S] = 1; REP(i, m) { auto dp1 = dp[i].begin() + S, dp2 = dp[i + 1].begin() + S; REP(j, -S, S) { if (dp1[j] == 0) continue; dp2[j] += dp1[j]; dp2[j + a[i]] += dp1[j]; dp2[j - a[i]] += dp1[j]; } } if (dp[m][S] == 1) { std::cout << "No" << std::endl; return 0; } Int curj = 0; std::vector b(n); for (int i = m - 1; i >= 0; i--) { auto dp1 = dp[i].begin() + S, dp2 = dp[i + 1].begin() + S; if (dp1[curj - a[i]] > 0) { b[i] = a[i]; curj -= a[i]; } else if (dp1[curj + a[i]] > 0) { b[i] = -a[i]; curj += a[i]; } else { b[i] = 0; } } assert(curj == 0); std::cout << "Yes" << std::endl; for (Int x : b) std::cout << x << " "; std::cout << std::endl; }