The mayor of the colorful world of Blocktopia has asked Bob the Builder to design $N-1$ buildings.
All buildings in Blocktopia are built from square blocks of various colors. A building of height $H$ can be seen as $H$ blocks stacked on top of each other.

He has also requested some strange requirements on the design of the buildings:

  • Every building must have the same height $H$.
  • Each building must be bicolored: it must use exactly 2 different colors of blocks.
  • Maximize the height $H$.

Bob has $N$ different colors of blocks, in which he has $A[i]$ blocks of the $i$-th color.

Bob may be an expert at construction, but he is no master at colors!
Can you help Bob determine the maximum height $H$ and provide a valid construction of the $N-1$ buildings?


valid design
Figure 1 | Illustrated by Sunny

As an example, this is a valid design of buildings.


invalid design
Figure 2 | Illustrated by Sunny

As an example, this is an invalid design of buildings.


Input

The first line contains a single integer $N$.
The next line contains $N$ integers, where the $i$-th integer is $A[i]$.

Output

Output the maximum height $H$ on the first line.
Then output $N-1$ lines describing each building with four integers: $i, x, j, y$: $i$ and $j$ denote the two colours that the building is made out of; and $x$ and $y$ denote the number of blocks used which are colors $i$ and $j$ respectively. The outputted numbers should satisfy the following:

  • $1\le i, j \le N$
  • $i\neq j$
  • $x+y=H$

If there are multiple solutions, output any of them. It is guaranteed that a solution exists under the given costraints.

Constraints

For all subtasks:
  • $2 \le N \le 5\times 10^5$
  • $2 \le A[i] \le 10^9$

Subtask 1 (15%): $N=3$
Subtask 2 (20%): All $A[i]$ are equal
Subtask 3 (40%): $N\le 10^3$
Subtask 4 (25%): No additional constraints

Sample Test Cases

Input Output
3
2 2 3
3
1 2 2 1
2 1 3 2
Click to copy.

Scoring: Per Subtask
Authored by s19x17
Appeared in 2023 Mini Contest 5 (JSOI Selection)