As the new school year begins, the school is hosting a grand "Rock, Paper, Scissors" tournament to welcome everyone back. students will participate in the tournament, where is a power of . Each student has a unique skill level from to , and when two students are matched against each other, the student with the higher skill level always wins. The students have been put into a specific order that was previously chosen by the organizers. The computer managing the tournament stores the details of the students in an array , , , ..., , where is the skill of the -th student. The computer will match the students as follows:
- The 1st student is matched against the 2nd student, the 3rd student is matched against the 4th student, the 5th student is matched against the 6th student, the 7th student is matched against the 8th student, and so on. The loser of each of the matches are then eliminated, whereas the winners progress to the next round.
- The winner of the match between the 1st and 2nd student is matched against the winner of the match between the 3rd and 4th student, the winner of the match between the 5th and 6th student is matched against the winner of the match between the 7th and 8th student, and so on. Again, the losers are eliminated, and the winners progress to the next round.
- This continues until there is one student remaining: the winner of the tournament.
In other words, the tournament is held in a single-elimination format.
Let the underwhelmingness of a match be defined as the square of the difference between the skills of the students in a match. Let inserting an element in an array at a index mean placing at the -th position in , and shifting all subsequent elements one position to the right.
After a brief power outage, the memory of the computer has become corrupted, and a random student has been deleted from ! To recover the original array , the missing student must be reinserted into the array. For every between and , determine the sum of the underwhelmingness of all matches played if the missing student was inserted at position .
Constraints
is a power of .
No two elements in are equal.
Input Specification
The first line of input contains one integer , the number of students participating in the tournament.
The second line of input contains integers, the array after a random student has been removed.
Output Specification
On one line, for every between and , print the sum of the underwhelmingness of all matches played if the missing student was inserted at position .
Sample Input
4
2 4 3
Sample Output
6 6 9 9
Explanation for Sample
The student that has been deleted has skill level .
If the missing student was inserted at index , the array would be . The st student would be matched against the nd student, and the rd student would be matched against the th student. The nd and rd students progress to the next round, where they would be matched against each other. The rd student has a higher skill level than the st student, and is the overall winner of the tournament. The sum of the underwhelmingness of all matches would be .
If the missing student was inserted at index , the array would be , and the sum of the underwhelmingness of all matches is .
If the missing student was inserted at index , the array would be , and the sum of the underwhelmingness of all matches is .
If the missing student was inserted at index , the array would be , and the sum of the underwhelmingness of all matches is .
Comments