Graph constructive problems are back! This time the graph you are asked to build should match the following properties.

The graph is connected if and only if there exists a path between every pair of vertices.

The diameter (aka "longest shortest path") of a connected undirected graph is the maximum number of edges in the shortest path between any pair of its vertices.

The degree of a vertex is the number of edges incident to it.

Given a sequence of n n integers a 1 ,a 2 ,…,a n  a1,a2,…,an construct a connected undirected graph of n n vertices such that:

  • the graph contains no self-loops and no multiple edges;
  • the degree d i  di of the i i -th vertex doesn't exceed a i  ai (i.e. d i ≤a i  di≤ai );
  • the diameter of the graph is maximum possible.

Output the resulting graph or report that no solution exists.

Input

The first line contains a single integer n n (3≤n≤500 3≤n≤500 ) — the number of vertices in the graph.

The second line contains n n integers a 1 ,a 2 ,…,a n  a1,a2,…,an (1≤a i ≤n−1 1≤ai≤n−1 ) — the upper limits to vertex degrees.

Output

Print "NO" if no graph can be constructed under the given conditions.

Otherwise print "YES" and the diameter of the resulting graph in the first line.

The second line should contain a single integer m m — the number of edges in the resulting graph.

The i i -th of the next m m lines should contain two integers v i ,u i  vi,ui (1≤v i ,u i ≤n 1≤vi,ui≤n , v i ≠u i  vi≠ui ) — the description of the i i -th edge. The graph should contain no multiple edges — for each pair (x,y) (x,y) you output, you should output no more pairs (x,y) (x,y) or (y,x) (y,x) .

Examples



Input

3
2 2 2



Output

YES 2
2
1 2
2 3



Input

5
1 4 1 1 1



Output

YES 2
4
1 2
3 2
4 2
5 2



Input

3
1 1 1



Output

NO


题意:构造一棵树,使得直径最长,需要满足每个点的度数di<=ai。

思路:我们选择ai最小的两个最为直径端点,然后把di>1的加到直径上去,剩下的度数为1的加到直径的枝桠上。

昨天没时间了没有写输出“NO”,WA3了。今天加上了就AC了。

给我30s可能就A了,加上最后一题水题没做。这一次CF血亏。



#include<bits/stdc++.h>
#define pii pair<int,int>
#define F first
#define S second
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int maxn=1000010;
int N,sum,L,S,T;
int b[maxn],ans; int f[maxn],c[maxn],tot;
pii a[maxn];
int main()
{
scanf("%d",&N); ans=1;
rep(i,1,N) scanf("%d",&a[i].F),a[i].S=i;
sort(a+1,a+N+1);
b[++L]=a[1].S; b[++L]=a[2].S;
int pre=b[1],bg=0;
rep(i,3,N){
if(a[i].F>1){
f[++tot]=pre,c[tot]=a[i].S,pre=a[i].S,ans++;
if(!bg) bg=i;
}
}
f[++tot]=pre,c[tot]=b[2];
int pos=bg,F=true;
rep(i,3,bg-1) {
if(a[i].F==1) {
while(a[pos].F<=2){
pos++; if(pos==N+1) {F=false; break;}
}
if(!F) break;
a[pos].F--; f[++tot]=a[i].S,c[tot]=a[pos].S;
}
else break;
}
if(!F||tot!=N-1) puts("NO");
else {
printf("YES %d\n%d\n",ans,N-1);
rep(i,1,tot) printf("%d %d\n",f[i],c[i]);
}
return 0;

}


 


It is your time to fight!