You have $$$n$$$ chicken jockeys, as one does, and you want to showcase them in your ULTIMATE ultra-secure OP hidden secret minecraft base in as square of a bounded area as possible. Each chicken jockey fills a 1 block by 1 block area on the floor. The $$$i^{th}$$$ chicken jockey has a height of $$$h_i$$$ chickens. You must lay the chicken jockeys out in a grid, where each chicken jockey is connected* to every other chicken jockey. Furthermore, every row and column must have at least one chicken jockey in it.
Finally, you MUST ensure that a chicken jockey is strictly taller than the one in front of it so that you can see each zombie's face, because otherwise what's the point (you love chickens and zombies).
Formally, if a chicken jockey $$$a$$$ is in row $$$i$$$ and column $$$j$$$ and another chicken jockey $$$b$$$ in row $$$i+k$$$ and column $$$j$$$ for $$$k \gt 0$$$, you must ensure that $$$h_a \lt h_b$$$. You can maximize the "squareness" of your minecraft base by minimizing the absolute difference between the number of rows and the number of columns used in your grid.
Given a list of chicken jockey heights, output the absolute difference of the dimensions of the most square bounded minecraft base such that you can see each zombie's face.
*Connected means you can reach any chicken jockey from another by take steps going up, down, left, or right walking on top of zombie heads.
The first line contains a single integer: $$$1\leq n \leq 10^5$$$, the number of chicken jockeys.
The next line contains $$$n$$$ integers, where $$$1\leq h_i \leq 10^9$$$ is the height of the $$$i^{th}$$$ chicken jockey.
One integer $$$d$$$, the absolute difference between the number of rows and columns of the squarest bounded base grid such that the chicken jockeys are connected and visible.
61 1 1 1 1 2
3
56 7 6 7 6
0
21 100
1
For the first test case, one valid configuration of chicken jockeys is the following:
This gives us 2 rows and 5 columns, or an absolute difference of 3.
| Название |
|---|


