#include #define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i)) #define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i)) #define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i)) #define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i)) #define ALL(x) ::std::begin(x), ::std::end(x) using namespace std; vector solve(int n, const vector & a) { { // find duplicated numbers unordered_map found; REP (i, n) { if (found.count(a[i])) { int j = found[a[i]]; vector x(n); x[i] = +1; x[j] = -1; return x; } found[a[i]] = i; } } { // find duplicated difference vector order(n); iota(ALL(order), 0); sort(ALL(order), [&](int i, int j) { return a[i] < a[j]; }); unordered_multimap > found; REP (i, n) { REP3 (j, i + 1, min(n, i + 1000)) { int64_t delta = a[order[j]] - a[order[i]]; for (auto [first, last] = found.equal_range(delta); first != last; ++ first) { auto [k, l] = first->second; if (k != i and k != j and l != i and l != j) { vector x(n); x[order[i]] = +1; x[order[j]] = -1; x[order[k]] = -1; x[order[l]] = +1; return x; } } found.emplace(delta, make_pair(i, j)); } } } // dp vector order(n); iota(ALL(order), 0); sort(ALL(order), [&](int i, int j) { return a[i] < a[j]; }); // shuffle(ALL(order), default_random_engine()); auto func = [&](int l, int r) { unordered_map cur, prv; REP3 (i, l, r) { int64_t a_i = a[order[i]]; prv = cur; cur.try_emplace(a_i, i); for (auto it : prv) { cur.try_emplace(it.first + a_i, i); cur.try_emplace(it.first - a_i, i); } if (cur.count(0)) { break; } } // for (auto it : cur) { // cerr << it.first << " (" << it.second << ")" << endl; // } return cur; }; auto cur = func(0, n); if (not cur.count(0)) { return vector(); } // reconstruct vector x(n); for (int64_t value = 0; ; ) { int i = cur[value]; int64_t a_i = a[order[i]]; if (value - a_i == 0) { x[order[i]] = +1; break; } else if (cur.count(value - a_i) and cur[value - a_i] < i) { x[order[i]] = +1; value -= a_i; } else if (cur.count(value + a_i) and cur[value + a_i] < i) { x[order[i]] = -1; value += a_i; } else { assert (false); } } return x; } // generated by online-judge-template-generator (https://github.com/kmyk/online-judge-template-generator) const string YES = "Yes"; const string NO = "No"; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); constexpr char endl = '\n'; int N; cin >> N; vector A(N); REP (i, N) { cin >> A[i]; } auto x = solve(N, A); if (x.empty()) { cout << NO << endl; } else { cout << YES << endl; REP (i, N) { cout << (A[i] * x[i]) << (i + 1 < N ? ' ' : '\n'); } } return 0; }