We’re preparing your current view and syncing the latest data.
You are given n soldiers standing in a line, each having a certain height. Your task is to bring the tallest soldier to the front of the line and the shortest soldier to the end of the line. You can only swap adjacent soldiers. Find the minimum number of such swaps required.
The first line contains an integer n (2 ≤ n ≤ 100) — the number of soldiers. The second line contains n integers h_1, h_2, ..., h_n (1 ≤ h_i ≤ 100) — the heights of the soldiers.
Print a single integer — the minimum number of swaps needed.
2 ≤ n ≤ 100 1 ≤ h_i ≤ 100