← Home
#include <bits/stdc++.h>
using namespace std;
 
int n;
vector<pair<int, int> > ai;
vector<int> heights;
vector<int> wizNums;
vector<int> target;
vector<pair<int, int> > housePos;
 
void solve() {
    if (n == 2 && ai[0].first != 0 && ai[1].first != 0 && ai[1].first != ai[0].first) {
        cout << "NO" << endl;
        return;
    }
    sort(ai.rbegin(), ai.rend());
    int col = 0;
    int dupInd = 0;
    bool hasDup = false;
    for (int i = 1; i < n; i++) {
        if (ai[i].first == ai[i - 1].first) {
            hasDup = true;
            dupInd = i - 1;
            break;
        }
    }
    bool usedDup = false;
    int loopTill = n;
    if (ai[n - 1].first == 0) {
        wizNums[col] = ai[n - 1].second;
        heights[col] = 0;
        loopTill = n - 1;
        target[ai[n - 1].second] = ai[n - 1].second;
        col = 1;
    } else if (hasDup) {
        usedDup = true;
        int dupNum = ai[dupInd].first;
        heights[1] = 0;
        heights[0] = dupNum - 1;
        target[ai[dupInd].second] = ai[dupInd + 1].second;
        target[ai[dupInd + 1].second] = ai[dupInd].second;
        wizNums[1] = ai[dupInd].second;
        wizNums[0] = ai[dupInd + 1].second;
        col = 2;
    } else {
        heights[2] = 0;
        heights[1] = 1;
        heights[0] = 1;
        wizNums[2] = ai[n - 3].second;
        wizNums[1] = ai[n - 2].second;
        wizNums[0] = ai[n - 1].second;
        target[ai[n - 3].second] = ai[n - 1].second;
        target[ai[n - 2].second] = ai[n - 3].second;
        target[ai[n - 1].second] = ai[n - 2].second;
        loopTill = n - 3;
        col = 3;
    }
    bool top = true;
    int i = 0;
    while (i < loopTill) {
        if (usedDup && (i == dupInd || i == dupInd + 1)) {
            i++;
            continue;
        }
        int lastHeight = heights[col - 1];
        int distNum = ai[i].first;
        int newHeight;
        if (ai[i].first == 0) {
            newHeight = 0;
            top = true;
            target[ai[i].second] = ai[i].second;
        } else if (top) {
            newHeight = lastHeight + distNum - 1;
            top = false;
            target[ai[i].second] = wizNums[col-1];
        } else {
            newHeight = lastHeight - distNum + 1;
            top = true;
            target[ai[i].second] = wizNums[col-1];
        }
        heights[col] = newHeight;
        wizNums[col] = ai[i].second;
        col++;
        i++;
    }
 
    // print sol
    cout << "YES\n";
    for (int j = 0; j < n; j++) {
        housePos[wizNums[j]] = make_pair(j, heights[j]);
    }
    for (int j = 1; j <= n; j++) {
        cout << housePos[j].first + 1 << " " << housePos[j].second + 1 << "\n";
    }
    cout << target[1];
    for (int j = 2; j <= n; j++) {
        cout << " " << target[j];
    }
    cout << endl;
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    cin >> n;
    ai = vector<pair<int, int> >(n);
    heights = vector<int>(n);
    wizNums = vector<int>(n);
    target = vector<int>(n+1);
    housePos = vector<pair<int, int> >(n + 1);
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        ai[i] = make_pair(tmp, i + 1);
        // dist, number
    }
    solve();
}