#include <bits/stdc++.h> #define int long long #define all(x) x.begin(), x.end() #define len(x) (int)(x.size()) #define mp make_pair #define pb push_back #define fi first #define se second using namespace std; typedef pair<int, int> pii; typedef long long ll; typedef long double ld; bool umin(int& a, int b) { if(b < a) { a = b; return true; } return false; } bool umax(int& a, int b) { if(b > a) { a = b; return true; } return false; } //#ifdef KoRoVa //#define DEBUG for (bool __DEBUG=1;__DEBUG;__DEBUG=0) //#define LOG(...) prnt(#__VA_ARGS__" ::",_VA_ARGS)<<endl //#else //#define DEBUG while(false) //#define LOG(...) if(false) //#endif template <class ...Ts> auto &prnt(Ts ...ts) { return ((cerr << ts << " "), ...); } const int max_n = -1, inf = 1000111222; const ll linf = 1000111222000111222; inline int brute (int n, int k, vector <int> a) { sort(all(a)); int ans = inf; do { int res = 0, sum = 0, cnt = 0; for (int i = 0; i < n; i++) { sum += a[i]; ++cnt; if (sum >= k || cnt == 3) { if (i + 1 < n) { ++res; } sum = 0; cnt = 0; } } umin(ans, res); } while (next_permutation(all(a))); return ans; } const int debug = false; const int C = 15; #define cerr if (false) cerr mt19937 rng(228); inline int randll(int l, int r) { return uniform_int_distribution<int>(l, r) (rng); } inline bool inside (int a, int b, int l, int r) { int d = abs(a) + abs(b); return l <= d && d <= r; } vector<pii> A, B; pii gg; inline ll det (int a, int b, int c, int d) { return a * d - b * c; } inline bool check_x (int x, int l, int r) { if (l > r) { swap(l, r); } return l <= x && x <= r; } inline bool point_on_seg (pii a, pii b, pii c) { b.first -= a.first; b.second -= a.second; c.first -= a.first; c.second -= a.second; if (det(b.first, b.second, c.first, c.second) == 0) { if (check_x(c.first, 0, b.first) && check_x(c.second, 0, b.second)) { gg = c; gg.first += a.first; gg.second += a.second; return true; } } return false; } struct line { int a, b, c; line (pii x, pii y) { a = x.second - y.second; b = y.first - x.first; c = -a * x.first - x.second * b; } }; inline bool check_int(pii a, pii b, pii c, pii d) { cerr << a.first << ' ' << a.second << '\n'; cerr << b.first << ' ' << b.second << '\n'; cerr << c.first << ' ' << c.second << '\n'; cerr << d.first << ' ' << d.second << '\n'; cerr << '\n'; if (point_on_seg(a, b, c)) { return true; } if (point_on_seg(a, b, d)) { return true; } if (point_on_seg(c, d, a)) { return true; } if (point_on_seg(c, d, b)) { return true; } line l1(a, b); line l2(c, d); ll go = det(l1.a, l1.b, l2.a, l2.b); if (go == 0) { return false; } ll x = det(-l1.c, -l2.c, l2.a, l2.b); ll y = det(l1.a, l1.b, -l1.c, -l2.c); if (x % go != 0) { return false; } if (y % go != 0) { return false; } x /= go; y /= go; gg = {x, y}; if (point_on_seg(a, b, gg) && point_on_seg(c, d, gg)) { return true; } return false; } inline bool intersect (int a, int b, int last, int r) { A = {{a - last, b}, {a, b + last}, {a + last, b}, {a, b - last}}; B = {{0 - r, 0}, {0, 0 + r}, {0 + r, 0}, {0, 0 - r}}; for (int i = 0; i < 4; i++) { int nxt = 0; if (i + 1 < 4) { nxt = i + 1; } for (int j = 0; j < 4; j++) { int NXT = 0; if (j + 1 < 4) { NXT = j + 1; } if (check_int(A[i], A[nxt], B[j], B[NXT])) { return true; } } } return false; } inline pii to (int a, int b, vector <int> d, int last) { if (d.empty()) { int res = abs(a) + abs(b); if (res != last) { cout << "NO\n"; exit(0); } return make_pair(0, 0); } sort(all(d)); reverse(all(d)); ll l = d[0], r = d[0]; for (int i = 1; i < len(d); i++) { l -= d[i]; r += d[i]; } if (l < 0) { l = 0; } if (inside(a - last, b, l, r)) { return make_pair(a - last, b); } cerr << "go\n"; if (intersect(a, b, last, l)) { return gg; } if (intersect(a, b, last, r)) { return gg; } cout << "NO\n"; exit(0); } void test_case() { int n, a, b; cin >> n >> a >> b; vector <int> d(n - 1); ll s = 0; for (int &i : d) { cin >> i; s += i; } s -= a; s -= b; if (s % 2 != 0) { cout << "NO\n"; return; } cerr << "HERE" << '\n'; vector <pii> ans = {{a, b}}; while (!d.empty()) { int last = d.back(); d.pop_back(); pii res = to(a, b, d, last); ans.pb(res); tie(a, b) = res; cerr << a << ' ' << b << '\n'; } cout << "YES\n"; reverse(all(ans)); for (auto &i : ans) { cout << i.first << ' ' << i.second << '\n'; } } signed main() { // freopen("input.txt", "r", stdin); ios_base::sync_with_stdio(false); cin.tie(nullptr); int testcases = 1; // cin >> testcases; while(testcases--) test_case(); exit(0); } /* 13 6 5 -2 7 0 0 -7 */