#include<bits/stdc++.h> #define ff first #define ss second #define pb push_back #define mp make_pair #define ll long long #define all(a) a.begin(),a.end() #define endl '\n' #define int ll using namespace std; const int N = 3e5 + 3; int n, a, b; pair<int, int> d[N]; int A[N], B[N]; int ans1[N], ans2[N]; void solve() { cin >> n >> a >> b; n--; for(int i = 1; i <= n; ++i) cin >> d[i].ff, d[i].ss = i; sort(d + 1, d + n + 1); int s1 = 0, s2 = 0; for(int i = 1; i <= n; ++i) { A[i] = d[i].ff; s1 += A[i]; } while(s2 < b) { for(int i = 1; i <= n; ++i) { if(A[i] > 0) { int mn = min(A[i], b - s2); mn = min(mn, s1 - a); s1 -= abs(A[i]); s2 -= abs(B[i]); A[i] -= mn; B[i] += mn; s1 += abs(A[i]); s2 += abs(B[i]); } } } int cntt = 0; while(s1 > a) { for(int i = 1; i <= n; ++i) { cntt++; if(A[i] <= 0) { int mn = min(s1 - a, B[i]); s1 -= abs(A[i]); s2 -= abs(B[i]); A[i] -= mn; B[i] -= mn; s1 += abs(A[i]); s2 += abs(B[i]); } } while(s2 < b) { for(int i = 1; i <= n; ++i) { cntt++; if(A[i] > 0) { int mn = min(A[i], b - s2); mn = min(mn, s1 - a); s1 -= abs(A[i]); s2 -= abs(B[i]); A[i] -= mn; B[i] += mn; s1 += abs(A[i]); s2 += abs(B[i]); } } } if(cntt > 10000000) { cout << "NO" << endl; return; } } while(s2 < b) { for(int i = 1; i <= n; ++i) { cntt++; if(A[i] > 0) { int mn = min(A[i], b - s2); mn = min(mn, s1 - a); s1 -= A[i]; s2 -= B[i]; A[i] -= mn; B[i] += mn; s1 += A[i]; s2 += B[i]; } } } cout << "YES" << endl; for(int i = 1; i <= n; ++i) { ans1[d[i].ss] = A[i]; ans2[d[i].ss] = B[i]; } for(int i = 1; i <= n; ++i) { ans1[i] += ans1[i - 1]; ans2[i] += ans2[i - 1]; cout << ans1[i] << ' ' << ans2[i] << endl; } } main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t; t = 1; while(t--) { solve(); } } /* 1 8 37 2 13 13 11 12 19 16 18 1 6 10 2 6 8 2 6 8 1 3 10 2 6 8 1 4 4 2 3 4 4 5 8 25 4 5 18 3 17 17 18 14 7 21 20 14 1 4 20 8 4 8 1 20 5 9 4 14 12 2 20 8 37 2 13 13 11 12 19 16 18 4 38 15 3 14 7 1 7 21 20 14 1 4 20 8 4 1 8 25 4 5 18 3 17 17 18 14 5 8 25 4 5 18 3 17 17 18 14 7 21 20 14 1 4 20 8 4 8 1 20 5 9 4 14 12 2 20 8 37 2 13 13 11 12 19 16 18 4 38 15 3 14 7 1 8 1 20 5 9 4 14 12 2 20 */