#include <bits/stdc++.h> using namespace std; struct stat { long long d; long long x, y; long long idx; int fl; }; const int maxn = 55; stat s[maxn]; bool cmp(stat i, stat j) { return i.d > j.d; } bool cmp2(stat i, stat j) { return i.idx < j.idx; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; int i, j; cin >> n; n--; long long fx, fy; cin >> fx >> fy; long long D = 0; for(i = 1; i <= n; i++) { cin >> s[i].d; s[i].idx = i; D += s[i].d; } if ((D - fx - fy) % 2 == 1 || ((D-fx-fy)<0)) { cout << "NO" << endl; return 0; } long long S = (D - fx - fy)/2; sort(s+1,s+n+1, cmp); if (S == 0) { sort(s+1,s+n+1,cmp2); long long currx = 0; long long curry = 0; cout << "YES" << endl; for(i = 1; i <= n; i++) { cout << currx << " " << curry << endl; long long p = min(s[i].d, fx); currx += p; fx -= p; s[i].d -= p; curry += s[i].d; fy -= s[i].d; } cout << currx << " " << curry << endl; return 0; } long long currSum = 0; long long currx = 0, curry = 0; //cout << S << endl; for(i = 1; i <= n && S - currSum > 0; i++) { if (s[i].d + currSum <= S) { if (fx > fy) { s[i].x = -s[i].d; s[i].y = 0; s[i].fl = -1; currx -= s[i].d; } else { s[i].x = 0; s[i].y = -s[i].d; s[i].fl = -1; curry -= s[i].d; } currSum += s[i].d; } else { if (s[i].d <= max(fx,fy)+ S) { //out << "OK " << i << endl; long long z = S - currSum; if (fx > fy) { s[i].y = -z; s[i].x = s[i].d - z; s[i].fl = 2; currx += s[i].x; curry += s[i].y; } else { s[i].x = -z; s[i].y = s[i].d - z; s[i].fl = 2; currx += s[i].x; curry += s[i].y; } currSum = S; break; } } } if (S != currSum) { cout << "NO" << endl; return 0; } sort(s+1,s+n+1, cmp2); long long DX = 0, DY = 0; cout << "YES" << endl; for(i = 1; i <= n; i++) { //cout << i << " :::: " << s[i].fl << endl; cout << DX << " " << DY << endl; if (s[i].fl != 0) { DX += s[i].x; DY += s[i].y; continue; } long long m = min(s[i].d, fx-currx); DX += m; DY += (s[i].d - m); currx += m; } cout << DX << " " << DY << endl; return 0; }