CF898E Squares and not squares

Description

Ann and Borya have $ n $ piles with candies and $ n $ is even number. There are $ a_{i} $ candies in pile with number $ i $ . Ann likes numbers which are square of some integer and Borya doesn't like numbers which are square of any integer. During one move guys can select some pile with candies and add one candy to it (this candy is new and doesn't belong to any other pile) or remove one candy (if there is at least one candy in this pile). Find out minimal number of moves that is required to make exactly $ n/2 $ piles contain number of candies that is a square of some integer and exactly $ n/2 $ piles contain number of candies that is not a square of any integer.

Input Format

First line contains one even integer $ n $ ( $ 2

Output Format

Output minimal number of steps required to make exactly $ n/2 $ piles contain number of candies that is a square of some integer and exactly $ n/2 $ piles contain number of candies that is not a square of any integer. If condition is already satisfied output 0.

Explanation/Hint

In first example you can satisfy condition in two moves. During each move you should add one candy to second pile. After it size of second pile becomes $ 16 $ . After that Borya and Ann will have two piles with number of candies which is a square of integer (second and fourth pile) and two piles with number of candies which is not a square of any integer (first and third pile). In second example you should add two candies to any three piles.