#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 < mxidx) { cout << "NO" << endl; return; } if(sum < a + b) { cout << "NO" << endl; return; } cout << "YES" << endl; ll x = 0, y = 0; cout << x << ' ' << y << endl; ll left = sum; for(int i = 0; i < n-1; i++) { ll dist = abs(a-x) + abs(b-y); ll w = d[i]; ll dx = 0, dy = 0; if(dist == left) { dx = min(w, max(-w, a-x)); dy = min(w-abs(dx), max(-w+abs(dx), b-y)); } else { ll can_waste = left - dist; // cerr << "can_waste = " << can_waste << endl; ll ineff = can_waste / 2; if(ineff >= w) { if(x >= a) { dx = w; } else { dx = -w; } } else { // cerr << "ineff = " << ineff << endl; if(x + w < a) { dx = w - ineff; dy = (y < b) ? -ineff : ineff; } else if(x - w > a) { dx = -(w - ineff); dy = (y < b) ? -ineff : ineff; } else if(y + w < a) { dy = w - ineff; dx = (y < b) ? -ineff : ineff; } else if(y - w > a) { dy = -(w - ineff); dx = (x < b) ? -ineff : ineff; } else { dx = (x < a) ? a - x + ineff : a - x - ineff; dy = (y < b) ? w - abs(dx) : -(w-abs(dx)); } } // if(x != a) { // dx = min(w, max(-w, a-x)); // } // dy = min(a-w, max(a-w), ) } x += dx; y += dy; cout << x << ' ' << y << endl; left -= d[i]; } assert(x == a && y == b); } int main() { ios::sync_with_stdio(false); cin.tie(0); solve(); return 0; }