#include <bits/stdc++.h> using namespace std; #define int long long #define F first #define S second const int INF = 1e16; mt19937 rng(time(nullptr)); int rnd(int B){ return (unsigned long long)rng()%B; } /* pair<int,int>get(int d, int a, int b, int l, int r){ for(int i = -d;i<=d;i++){ int j1 = d-abs(i); int j2 = -j1; int D = abs(i-a)+abs(j1-b); if(l<=D && D<=r)return {i,j1}; D = abs(i-a)+abs(j2-b); if(l<=D && D<=r)return {i,j2}; } assert(1==0); return {INF,INF}; }*/ pair<int,int>get(int d, int a, int b, int l, int r){ vector<int>test; test.push_back(d+r+a +b); test.push_back(d-r+a +b); test.push_back(d+r-a +b); test.push_back(d-r-a +b); test.push_back(d+r+a -b); test.push_back(d-r+a -b); test.push_back(d+r-a -b); test.push_back(d-r-a -b); test.push_back(d+l+a +b); test.push_back(d-l+a +b); test.push_back(d+l-a +b); test.push_back(d-l-a +b); test.push_back(d+l+a -b); test.push_back(d-l+a -b); test.push_back(d+l-a -b); test.push_back(d-l-a -b); for(int i = 0;i<16;i++)test.push_back(-test[i]); for(auto i : test){ assert(i%2==0); if(abs(i/2)>d)continue; i/=2; int j1 = d-abs(i); int j2 = -j1; int D = abs(i-a)+abs(j1-b); if(l<=D && D<=r)return {i,j1}; D = abs(i-a)+abs(j2-b); if(l<=D && D<=r)return {i,j2}; } assert(1==0); return {INF,INF}; } signed main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin>>n; int a,b; cin>>a>>b; n--; vector<pair<int,int>>d(n); int par = 0; vector<int>suf(n+2,0); for(int i = 0;i<n;i++){ cin>>d[i].F; d[i].S = i; par+=d[i].F; } sort(d.begin(),d.end()); for(int i = n-1;i>=0;i--)suf[i] = suf[i+1]+d[i].F; if(suf[0]<a+b || (par%2!= (a+b)%2) || d[0].F-suf[1]>a+b){ cout<<"NO"<<endl; return 0; } int l = d[0].F; int r = d[0].F; vector<pair<int,int>>ans(n); int A = a; int B = b; for(int i = 0;i<n;i++){ r = suf[i+1]; l = max(0LL, d[i+1].F -suf[i+2]); ans[d[i].S] = get(d[i].F, a,b,l,r); a-= ans[d[i].S].F; b-= ans[d[i].S].S; } cout<<"YES"<<endl; int px = 0; int py = 0; for(int i = 0;i<n;i++){ cout<<px<<" "<<py<<endl; px+=ans[i].F; py+=ans[i].S; } cout<<px<<" "<<py<<endl; }