Print the total number of times Akaki looks at the top card of the deck.
Enter |
Output |
4
6 3 1 2
|
7 |
1
1000
|
1 |
7
3 3 3 3 3 3 3
|
7 |
Note
In the first example, Akaki will first look at the card with the number 6, put it at the bottom of the deck, then the card with the number 3, also put it at the bottom of the deck, and then the card with the number 1. He will put the card with the number 1 aside, since it contains the minimum number from remaining in the deck. After that, the cards in the deck will lie in the order [2, 6, 3] from top to bottom. After that, Akaki will look at the top card with the number 2 and put it aside. After that, the cards in the deck will lie in the order [6, 3] from top to bottom. Then Akaki will look at the card with the number 6, put it on the bottom of the deck, and then the card with the number 3, which he will set aside. After that, one card with the number 6 will remain in the deck, which Akaki will look at and set aside. Thus, Akaki will look at 7 cards.