#881
Gold III
TURBO
시간 제한
1s
메모리 제한
32MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Frane has been given the task of sorting an array of numbers. The array consists of N integers, each between 1 and N (inclusive), with each of those appearing exactly once in the array. Frane has come up with the following sorting algorithm which operates in N phases, and named it turbosort:

  • In the first phase, the number 1 is moved to position 1 by repeatedly swapping consecutive

elements.

  • In the second phase, the number N is moved to position N in the same manner.

  • In the third phase, the number 2 is moved to position 2.

  • In the fourth phase, the number N−1 is moved to position N−1.

  • And so on.

In other words, when the number of the phase is odd, Frane will choose the smallest number not yet chosen, and move it to its final position. In even phases he chooses the largest number not yet chosen. Write a program which, given the initial array, output the number of swaps in each phase of the algorithm.

입력

The first line contains an integer N (1 ≤ N ≤ 100 000), the number of elements in the array. Each of the following N lines contains an integer between 1 and N (inclusive), the array to be sorted. The array will contain no duplicates.

출력

For each of the N phases, output the number of swaps on a single line.

예제 입력 1

3
2
1
3

예제 출력 1

1
0
0

예제 입력 2

5
5
4
3
2
1

예제 출력 2

4
3
2
1
0

예제 입력 3

7
5
4
3
7
1
2
6

예제 출력 3

4
2
3
0
2
1
0
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Gold III1명 투표· 약 1개월 전
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.