Asadullo is an outstanding researcher at APIO (Alliance for Power and Industrial Optimization). Recently, he has been studying a method to generate energy using an unknown material.
This unknown material does not produce energy on its own, but if there are several extremely long rods made of this material, they can generate energy through their interactions.
Specifically, there are rods, given by an array . The -th rod can be positioned at an angle of , with respect to the positive direction of the x-axis, in counterclockwise. The energy efficiency by these rods is defined as
where represents the acute angle formed between the -th rod and the -th rod. In this problem, we consider as an acute angle.
More formally, .
In other words, the energy efficiency is calculated by adding the acute angles between every pair of rods.
For example, if and correspondingly, , we would get the following graph:

Here, acute(0, 1) = 7500 (i.e. 27°), acute(0, 2) = 17500 (i.e. 63°), and acute(1, 2) = 25000 (i.e. 90°). Therefore, the energy efficiency of these rods equals .
Asadullo wants to adjust the arrangement of these rods to maximize their energy efficiency. However, there are several constraints:
Under these constraints, Asadullo wants to perform operations optimally to maximize the energy efficiency of the rods. Write a program to help Asadullo achieve the highest possible energy efficiency.
You should implement the following procedure:
void energy(int n, std::vector<int> v)
Within this procedure, you may call the following procedure:
void rotate(std::vector<int> t, int x)
Consider the following call:
energy(2, [20000, 10000])
Here, and the initial energy efficiency equals . One of the possible scenarios is the following:
rotate([0, 1], 8000). Then becomes . The energy efficiency stays the same.rotate([0], 15000). Then becomes . The energy efficiency becomes .It can be shown that for the given input, 25000 is the maximum possible energy efficiency. Therefore, Asadullo can stop performing these operations.
Consider the following call:
energy(3, [5000, 12500, 37500])
The image for this example was presented above. It can be shown that the initial energy efficiency is the maximum possible. Thus, no operations are needed.
The sample grader reads the input in the following format:
The sample grader prints the output in the following format:
Also, the grader will write detailed information about the rotations you made in the file log.txt.