#include <bits/stdc++.h> using namespace std; typedef long long ll; void solve(){ int n;cin>>n; ll a,b;cin>>a>>b; n--; vector<array<ll,2>> ans; vector<ll> pref(n+1,0); vector<ll> dist(n+1,0); for(int i =1;i<=n;i++){ cin>>dist[i]; pref[i]=pref[i-1]+dist[i]; } ans.push_back({a,b}); int ok = 1; ok&= pref[n] >= a+b; ok&= (a+b)%2 == pref[n]%2; if(!ok){ cout<<"NO\n";return; } // construction int cur = n; // pod crto while(b + dist[cur] < -a + pref[cur-1]){ ll na = a,nb= b + dist[cur]; a=na,b=nb; ans.push_back({a,b}); cur--; } // binsearchamo intersection if(pref[cur] == a+b){ }else { ll l = 0, r = dist[cur], bans = dist[cur];// bans je kok damo na b while (l <= r) { ll mid = (l + r) / 2; ll aa = dist[cur] - mid, bb = mid; if (b + mid + (a-aa) >= pref[cur]) { bans = min(bans, mid); r = mid - 1; } else l = mid + 1; } a -= dist[cur] - bans, b += bans; cur--; ans.push_back({a, b}); } if(a+b != pref[cur]){ cout<<"NO\n";return; } // on the line^tm while(b != 0 && cur > 0){ if(dist[cur] <= abs(b)){ int dir = b > 0 ? -1 : 1; b+=dir*dist[cur]; cur--; ans.push_back({a,b}); }else{ int dir = a > 0 ? -1 : 1; a += dir*(dist[cur]-b); b=0; cur--; ans.push_back({a,b}); } } while(cur > 0){ int dir = a > 0 ? -1 : 1; a+=dir*dist[cur]; cur--; ans.push_back({a,b}); } //printout reverse(ans.begin(),ans.end()); ll x= 0,y=0; for(int i = 1;i <=n;i++) { auto c = ans[i][0],d = ans[i][1]; if(abs(c-x) + abs(d-y) != dist[i]){ cout<<"NO\n";return; } x=c,y=d; } cout<<"YES\n"; for(auto&[c,d]:ans) { cout<<c<<" "<<d<<"\n"; } } int main(){ ios_base::sync_with_stdio(0),cin.tie(0); int t=1;//cin>>t; while(t--) solve(); } /* * * 5 10 6 0 7 8 5 16 0 1 0 0 0 0 0 1 1 1 1 1 2 2 2 3 3 3 0 1 1 3 3 */