#include <bits/stdc++.h> using namespace std; #define nl "\n" #define nf endl #define ll long long #define pb push_back #define _ << ' ' << #define INF (ll)1e18 int main() { ios::sync_with_stdio(0); cin.tie(0); ll n; cin >> n; n--; ll stx, sty; cin >> stx >> sty; ll tx = stx + sty, ty = stx - sty; // cout << "tx, ty =" _ tx _ ty << nf; vector<ll> d(n + 1, 0); for (ll i = 1; i <= n; i++) cin >> d[i]; auto calc_squares = [&](ll start) { ll tot = 0, mx = 0; for (ll i = start; i <= n; i++) tot += d[i], mx = max(mx, d[i]); return array<ll, 2>{tot, max((ll)0, 2 * mx - tot)}; }; auto inside = [&](ll x, ll y, ll out, ll in) { x = abs(x); y = abs(y); return (in <= x && x <= out && in <= y && y <= out); }; auto segments = [&](ll out, ll in, ll y) { vector<array<ll, 2>> v; if (in <= abs(y) && abs(y) <= out) { v.pb({-out, out}); } else if (abs(y) <= in) { v.pb({-out, -in}); v.pb({in, out}); } return v; }; auto find_intersection = [&](ll l1, ll r1, ll l2, ll r2) { if (max(l1, l2) > min(r1, r2)) return -INF; return max(l1, l2); }; auto sub = [&](ll star, ll l, ll r) { return array<ll, 2>{star - r, star - l}; }; vector<array<ll, 2>> ans(1, {0, 0}); ll ans_flag = 1; ll x = 0, y = 0; for (ll i = 1; i <= n; i++) { ll curr = d[i]; auto [out, in] = calc_squares(i + 1); ll star_x = tx - x, star_y = ty - y; // cout << "next" _ out _ in << nf; // cout << "star" _ star_x _ star_y << nf; ll flag = 0; ll vec_x = 0, vec_y = 0; { ll y = curr; // cout << "y =" _ y << nf; ll y_next = star_y - y; auto sides = segments(out, in, y_next); ll l_curr = -curr, r_curr = curr; auto [l, r] = sub(star_x, l_curr, r_curr); for (auto [cl, cr] : sides) { // cout << "l, r, cl, cr =" _ l _ r _ cl _ cr << nf; ll fi = find_intersection(l, r, cl, cr); if (fi != -INF) { flag = 1; vec_x = star_x - fi; vec_y = y; } } } { ll y = -curr; // cout << "y =" _ y << nf; ll y_next = star_y - y; auto sides = segments(out, in, y_next); ll l_curr = -curr, r_curr = curr; auto [l, r] = sub(star_x, l_curr, r_curr); for (auto [cl, cr] : sides) { // cout << "l, r, cl, cr =" _ l _ r _ cl _ cr << nf; ll fi = find_intersection(l, r, cl, cr); if (fi != -INF) { flag = 1; vec_x = star_x - fi; vec_y = y; } } } { ll x = curr; // cout << "x =" _ x << nf; ll x_next = star_x - x; auto sides = segments(out, in, x_next); ll l_curr = -curr, r_curr = curr; auto [l, r] = sub(star_y, l_curr, r_curr); for (auto [cl, cr] : sides) { // cout << "l, r, cl, cr =" _ l _ r _ cl _ cr << nf; ll fi = find_intersection(l, r, cl, cr); if (fi != -INF) { flag = 1; vec_x = x; vec_y = star_y - fi; } } } { ll x = -curr; // cout << "x =" _ x << nf; ll x_next = star_x - x; auto sides = segments(out, in, x_next); ll l_curr = -curr, r_curr = curr; auto [l, r] = sub(star_y, l_curr, r_curr); for (auto [cl, cr] : sides) { // cout << "l, r, cl, cr =" _ l _ r _ cl _ cr << nf; ll fi = find_intersection(l, r, cl, cr); if (fi != -INF) { flag = 1; vec_x = x; vec_y = star_y - fi; } } } if (flag == 0) { ans_flag = 0; } else { x += vec_x; y += vec_y; assert((x + y) % 2 == 0); ll orig_x = (x + y) / 2, orig_y = (x - y) / 2; // cout << orig_x _ orig_y << nl; ans.pb({orig_x, orig_y}); } // cout << "final" _ flag _ vec_x _ vec_y << nf; } if (ans_flag == 0) { cout << "NO" << nl; } else { cout << "YES" << nl; for (auto [x, y] : ans) { cout << x _ y << nf; } for (ll i = 1; i <= n; i++) { auto [x, y] = ans[i]; auto [xp, yp] = ans[i - 1]; assert(abs(x - xp) + abs(y - yp) == d[i]); } } }