Please, try EDU on Codeforces! New educational section with videos, subtitles, texts, and problems.
×

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

D. Degree Set

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputYou are given a sequence of *n* positive integers *d* _{1}, *d* _{2}, ..., *d* _{ n} ( *d* _{1} < *d* _{2} < ... < *d* _{ n}). Your task is to construct an undirected graph such that:

- there are exactly
*d*_{ n}+ 1 vertices; - there are no self-loops;
- there are no multiple edges;
- there are no more than 10
^{6}edges; - its degree set is equal to
*d*.

Vertices should be numbered 1 through (*d* _{ n} + 1).

Degree sequence is an array *a* with length equal to the number of vertices in a graph such that *a* _{ i} is the number of vertices adjacent to *i*-th vertex.

Degree set is a sorted in increasing order sequence of all distinct values from the degree sequence.

It is guaranteed that there exists such a graph that all the conditions hold, and it contains no more than 10^{6} edges.

Print the resulting graph.

Input

The first line contains one integer *n* (1 ≤ *n* ≤ 300) — the size of the degree set.

The second line contains *n* integers *d* _{1}, *d* _{2}, ..., *d* _{ n} (1 ≤ *d* _{ i} ≤ 1000, *d* _{1} < *d* _{2} < ... < *d* _{ n}) — the degree set.

Output

In the first line print one integer *m* (1 ≤ *m* ≤ 10^{6}) — the number of edges in the resulting graph. It is guaranteed that there exists such a graph that all the conditions hold and it contains no more than 10^{6} edges.

Each of the next *m* lines should contain two integers *v* _{ i} and *u* _{ i} (1 ≤ *v* _{ i}, *u* _{ i} ≤ *d* _{ n} + 1) — the description of the *i*-th edge.

Examples

Input

3

2 3 4

Output

8

3 1

4 2

4 5

2 5

5 1

3 2

2 1

5 3

Input

3

1 2 3

Output

4

1 2

1 3

1 4

2 3

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jul/08/2020 08:00:55 (f1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|