Тема: Who are you, Mister Graph?
Given degrees of a graph vertices, determine whether they conform to any undirected graph.
If so - output it. It is guaranteed that in the case when the graph exists, the number of edges does not exceed 500000. The graph should not contain loops and multiple edges.
*loop = петля
----------------------------
The first line of the input file contains an integer N - the number of vertices in the graph (1 < N <= 10000).
N numbers are written in the next line: d1, d2, ..., dn - the degrees of vertices (0 <= di <= 10000). Numbers in the line are separated by spaces.
-----------------------------
Write "YES" or "NO" - depending on the existence of a graph.
If yes, the first line should contain M - the number of edges in the resulting graph, and the following M lines must contain the description of each edge - numbers of vertices, that are the ends of the corresponding edge. Vertices are numbered starting from one in the order they are given in the input file.
If there are multiple graphs satisfying the condition, output any.
----------------------------
например:
input
4
2 1 2 3
output
YES
4
4 3
4 1
4 2
3 1