Yo`nalishlar
Hozirda online

Statistika

Masalalar soni: 909

Foydalanuvchilar soni: 8824

Jo'natishlar soni: 714622

Muhokama yozuvlari: 4541

Yangiliklar soni: 98

Yangiliklar izohlari: 1177


So'ngi izohlar

765. Minimum method
Vaqt limiti: 1 sekund
Xotira limiti: 64 MB

The array is sorted with selection sort in ascending order. How many times does the first element in initial array change its position?

  Input

The first line contains the number of elements in array n (1  n  1000). The second line contains the elements of array. It is known that all elements in array are different and not greater than 109 by absolute value.

  Output

Print the number of movements of the first element.

  Samples

Input

Output

1

3

1 3 2

0

2

2

2 1

1

3

4

4 1 5 3

3

 

Tayyorladi: Azat Yusupov
Text from: e-olimp.com
Mening urinishlarim(0) Muhokama (0) Jo'natish Eng yaxshi yechimlar Barcha muvaffaqiyatli urinishlar(39) Barcha urinishlar(86)