#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using pii = pair<int ,int>; using vpii = vector<pair<int, int>>; using pipii = pair<int, pii>; using vll = vector<ll>; void solve() { int n; cin >> n; ll a, b; cin >> a >> b; vll d(n-1); ll sum = 0; for(int i = 0; i < n-1; i++) { cin >> d[i]; sum += d[i]; } if((a+b+sum) % 2 == 1) { cout << "NO" << endl; return; } int mxidx = max_element(d.begin(), d.end()) - d.begin(); ll rest = sum - d[mxidx]; if(rest + a + b < d[mxidx]) { cout << "NO" << endl; return; } if(sum < a + b) { cout << "NO" << endl; return; } vector<pair<ll, int>> sor; for(int i = 0; i < n-1; i++) { sor.push_back({d[i], i}); } sort(sor.begin(), sor.end()); ll rem = sum; rem -= sor[n-2].first; vector<pair<ll, ll>> ans(n-1); for(int i = n-2; i >= 0; i--) { int j = sor[i].second; ll dist = abs(a) + abs(b); ll d = sor[i].first; // cerr << "d = " << d << endl; if(i > 0) rem -= sor[i-1].first; ll inner = i == 0 ? 0 : max(0ll, sor[i-1].first - rem); ll outer = i == 0 ? 0 : sor[i-1].first + rem; // cerr << "inner = " << inner << " outer = " << outer << endl; // cerr << "a = " << a << " b = " << b << endl; auto check = [&](int dx, int dy) { if(abs(dx) + abs(dy) != d) { return false; } ll t = abs(a-dx) + abs(b-dy); // cerr << "t = " << t << endl; if(inner <= t && t <= outer) { // cerr << dx << ' ' << dy << endl; return true; } return false; }; auto calc_inter = [&](ll pos, ll neg) -> pair<ll, ll> { // solves // x + y = pos // x - y = neg return {(pos + neg) / 2, (pos - neg) / 2}; }; { ll dx = 0; ll dy = d; if(check(dx, dy)) { ans[j] = {dx, dy}; a -= dx; b -= dy; continue; } } { ll dx = 0; ll dy = -d; if(check(dx, dy)) { ans[j] = {dx, dy}; a -= dx; b -= dy; continue; } } { ll dx = d; ll dy = 0; if(check(dx, dy)) { ans[j] = {dx, dy}; a -= dx; b -= dy; continue; } } { ll dx = -d; ll dy = 0; if(check(dx, dy)) { ans[j] = {dx, dy}; a -= dx; b -= dy; continue; } } bool good = false; vll my_pos = vll{d, -d}; vll ot_pos = vll{a+b+inner, a+b-inner, a+b+outer, a+b-outer}; vll my_neg = vll{d, -d}; vll ot_neg = vll{a-b+inner, a-b-inner, a-b+outer, a-b-outer}; for(int mp : my_pos) { for(int on : ot_neg) { if(good) continue; auto [dx, dy] = calc_inter(mp, on); if(check(dx, dy)) { ans[j] = {dx, dy}; a -= dx; b -= dy; good = true; } } } for(int op : ot_pos) { for(int mn : my_neg) { if(good) continue; auto [dx, dy] = calc_inter(op, mn); if(check(dx, dy)) { ans[j] = {dx, dy}; a -= dx; b -= dy; good = true; } } } if(good) continue; // { // ll dx = a; // if(abs(dx) <= d) { // ll dy = d - abs(a); // cerr << "4 " << dx << ' ' << dy << endl; // if(check(dx, dy)) { // ans[j] = {dx, dy}; // a -= dx; // b -= dy; // continue; // } // } // } // { // ll dx = a; // if(abs(dx) <= d) { // ll dy = -(d - abs(a)); // cerr << "5 " << dx << ' ' << dy << endl; // if(check(dx, dy)) { // ans[j] = {dx, dy}; // a -= dx; // b -= dy; // continue; // } // } // } // { // ll dy = b; // if(abs(dy) <= d) { // ll dx = d - abs(b); // if(check(dx, dy)) { // ans[j] = {dx, dy}; // a -= dx; // b -= dy; // continue; // } // } // } // { // ll dy = b; // if(abs(dy) <= d) { // ll dx = -(d - abs(b)); // if(check(dx, dy)) { // ans[j] = {dx, dy}; // a -= dx; // b -= dy; // continue; // } // } // } assert(false); } assert(a == 0 && b == 0); cout << "YES" << endl; ll x = 0, y = 0; cout << x << ' '<< y << endl; for(int i = 0; i < n-1; i++) { x += ans[i].first; y += ans[i].second; cout << x << ' '<< y << endl; } } int main() { ios::sync_with_stdio(false); cin.tie(0); solve(); return 0; }