#include <vector> #include <iostream> #include <map> #include <algorithm> #define ll long long #define all(x) x.begin(), x.end() #define ve vector #define vi vector<int> #define vvi vector<vector<int>> #define pb push_back #define pii pair<int, int> using namespace std; template <class T> istream& operator >>(istream&in, vector<T>&v) { for(T&el : v) { in >> el; } return in; } template <class T> ostream& operator <<(ostream&out, vector<T>&v) { out <<"{"; for(T&el : v) { out << el << ' '; } out <<"}"; return out; } #define int ll int cdist(int a, int b, int c, int d) { return abs(a - c) + abs(b - d); } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; int xf, yf; cin >> xf >> yf; vi dist(n - 1); cin >> dist; vi prefmx = dist; int sm = dist.back(); for (int i = n - 3; i >= 0; --i) { sm += dist[i]; prefmx[i] = max(prefmx[i+1],prefmx[i]); } if (sm % 2 != (xf + yf) % 2 || sm < abs(xf) + abs(yf) || prefmx[0] * 2 - sm > abs(xf) + abs(yf)) { cout << "NO\n"; return 0; } int cx = 0, cy = 0; cout << "YES\n"; cout << cx << ' ' << cy << "\n"; for (int i = 0; i < n - 2; ++i) { int mx = prefmx[i+1], sm1 = sm - dist[i]; int mind = mx * 2 - sm1; int step = dist[i]; if (cx + step <= xf || cx - step >= xf) { int up = cx + step <= xf ? 1 : -1; if (cdist(cx+step, cy, xf, yf) >= mind) { cx += step * up; } else { int exd = mind - cdist(cx+step, cy, xf, yf); cx += (step -exd/2) * up; if (cy < yf) cy -= exd/2; else cy += exd/2; } } else { int neex = abs(xf - cx); int ri = cx < xf ? 1 : -1; int up = cy < yf ? 1 : -1; if (cdist(xf, cy + up * (step - neex), xf, yf) >= mind) { cx = xf; cy = cy + up * (step - neex); } else { int exd = mind - cdist(xf, cy + up * (step - neex), xf, yf); if ((up==1 && (cy + step - neex < yf)) || (up==-1 && (cy - (step - neex) > yf))) { cx = xf + (exd/2) * ri; cy = cy + up * (step - neex - exd/2); } else { int exy = abs(cy + up * (step - neex) - yf); cx = xf - ri * (exd/2); cy = cy + up * (step - neex) + up * (exd/2); } } } sm -= dist[i]; cout << cx << ' ' << cy << '\n'; } cout << xf << ' ' << yf << "\n"; }