#include<bits/stdc++.h> using namespace std; #define int long long signed main(){ //ios::sync_with_stdio(false); //cin.tie(0); int n; cin>>n; long long a,b; cin>>a>>b; n--; vector<long long> d(n); long long sum=0; for(auto &i : d){ cin>>i; sum+=i; } long long k = (sum-(a+b)); //cout<<sum<<"\n"; if(k<0 || k%2!=0){ //cout<<k<<" ecco\n"; cout<<"NO\n"; return 0; }else{ k = k/2; long long x = a+k; long long curr=0,rim=0; for(auto i : d){ if(curr+i<x){ curr+=i; }else{ long long tmp = curr+i-x; if(tmp>=k){ tmp=min(k,i-tmp); }else{ tmp=min(tmp,i-tmp); } rim = tmp; break; } } //cout<<rim<<" rim\n"; k-=rim; assert(k>=0); sort(d.begin(),d.end()); if(d.back()>max(a,b)+k+rim){ cout<<"NO\n"; return 0; } if(d.back()>b+k+rim)reverse(d.begin(),d.end()); rim = -rim; // (0,0)->(a+k,rim)->(a,b) cout<<"YES\n"; bool first = true; long long px=0,py=0; for(auto i : d){ if(first){ if(py>rim){ long long tmp = min(py-rim,i); i-=tmp; py-=tmp; } if(px<a+k){ long long tmp = min(a+k-px,i); i-=tmp; px+=tmp; } //assert(i==0); if(px==a+k && py==rim){ first=false; } } if(!first){ if(py<b){ long long tmp = min(b-py,i); i-=tmp; py+=tmp; } if(px>a){ long long tmp = min(px-a,i); i-=tmp; px-=tmp; } } assert(i==0); cout<<px<<" "<<py<<"\n"; } } }