func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class T, class T2>   inline int chkmax(T &x, const T2 &y) {     return x < y ? x = y, 1 : 0;   }   template <class T, class T2>   inline int chkmin(T &x, const T2 &y) {     return x > y ? x = y, 1 : 0;   }   const int MAXN = (1 << 20);   int n, sum = 0;   vector<int> li1;   vector<pair<int, int> > li;   void read() {     cin >> n;     for (int i = 1; i <= n; i++) {       int x;       cin >> x;       if (x == 1)         li1.push_back(i);       else         sum += x - 2, li.push_back({x - 2, i});     }   }   vector<pair<int, int> > answer;   void solve() {     if (sum < ((int)li1.size()) - 2) {       cout <<  NO  <<   n ;       return;     }     int d = ((int)li.size()) - 1;     for (int i = 0; i < ((int)li.size()) - 1; i++)       answer.push_back({li[i].second, li[i + 1].second});     if (((int)li1.size()) >= 1) {       int x = li1.back();       li1.pop_back();       answer.push_back({x, li[0].second});       d++;     }     if (((int)li1.size()) >= 1) {       int x = li1.back();       li1.pop_back();       answer.push_back({x, li.back().second});       d++;     }     for (auto &it : li) {       while (it.first >= 1 && ((int)li1.size())) {         int x = li1.back();         li1.pop_back();         answer.push_back({x, it.second});         it.first--;       }     }     cout <<  YES           <<     << d <<   n ;     cout << ((int)answer.size()) <<   n ;     for (auto e : answer) cout << e.first <<     << e.second <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     read();     solve();     return 0;   }   