Problem Statement
There are $N$ children, numbered $1$ to $N$.
Child $i$ has $A_i$ candies.
Your goal is to execute the following operation as few times as possible so that eventually all $N$ children have the same number of candies.
- Choose two distinct children
$x,y$, and choose a positive integer$z$not exceeding the number of candies child$x$has. Take$z$candies from child$x$and give them to child$y$.
Determine whether there exists a sequence of operations such that eventually all $N$ children have the same number of candies. If it exists, find one such sequence with the minimum number of operations.
Constraints
$2 \leq N \leq 20$$1 \leq A_i \leq 10^8$- All input values are integers.
Input
The input is given from Standard Input in the following format:
N
A_1 \dots A_N
Output
If there is no sequence of operations such that eventually all $N$ children have the same number of candies, output -1.
If it exists, output one with the minimum number of operations in the following format:
q
x_1 y_1 z_1
\vdots
x_q y_q z_q
Here, $q$ represents the number of operations, and $x_i,y_i,z_i$ represent the values of $x,y,z$ chosen in the $i$-th operation.
If there are multiple solutions, outputting any of them will be considered correct.
样例
4
1 7 4 8
3
2 3 1
2 4 1
4 1 4
2
100 3
-1
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。