There are N players (numbered from 0 to N-1) participating in a tournament. The k-th player's skill level is skills[k]. No two players have the same skill level.
The tournament is played in rounds for as long as there are at least two players remaining. A single round of the tournament consists of one or more matches. In a match, two players compete against each other. The loser is eliminated and the winner advances to the next round. In the first round player 0 faces player 1, player 2 faces player 3, etc. In the second round the winner of the match between player 0 and player 1 faces the winner of the match between player 2 and player 3, etc. The player with the higher skill level wins the match.
For example, for skills = [4, 2, 7, 3, 1, 8, 6, 5], the tournament is as follows (numbers in circles are skill levels)