#include void add_BIT(int N, int BIT[], int i, int k) { while (i <= N) { BIT[i] += k; i += (i & -i); } } int sum_BIT(int BIT[], int r) { int sum = 0; while (r > 0) { sum += BIT[r]; r -= (r & -r); } return sum; } int memo[200001]; int recursion(int N, int l, int P_inv[], int BIT[], int ans[][2]) { if (l > N) return 1; else if (memo[l] != 0) return 0; int i, k; for (i = l + 1; i <= N; i++) { k = sum_BIT(BIT, P_inv[i] - 1); if (k % 2 != 0) break; add_BIT(N, BIT, P_inv[i], 1); ans[i-l-1][0] = i; ans[i-l-1][1] = k + 1; } for (i--; i >= l; i--) { k = sum_BIT(BIT, P_inv[l] - 1); if (k % 2 == 0) { add_BIT(N, BIT, P_inv[l], 1); ans[i-l][0] = l; ans[i-l][1] = k + 1; if (recursion(N, i + 1, P_inv, BIT, ans[i-l+1]) != 0) return 1; add_BIT(N, BIT, P_inv[l], -1); } if (i > l) add_BIT(N, BIT, P_inv[i], -1); } memo[l] = -1; return 0; } int solve(int N, int P[], int ans[][2]) { static int i, P_inv[200001], BIT[200001]; for (i = 1; i <= N; i++) { P_inv[P[i]] = i; BIT[i] = 0; memo[i] = 0; } return recursion(N, 1, P_inv, BIT, ans[1]); } int main() { int i, N, P[200001], ans[200001][2]; scanf("%d", &N); for (i = 1; i <= N; i++) scanf("%d", &(P[i])); if (solve(N, P, ans) == 0) printf("No\n"); else { printf("Yes\n"); for (i = 1; i <= N; i++) printf("%d %d\n", ans[i][0], ans[i][1]); } fflush(stdout); return 0; }