CodeLab Academy 📞 9936 6696
← List Python · Level 8: Nested loops Code · 80 points ← #773 #775 →

#774. Swaps in selection sort

In selection sort, for each i find the smallest (first) element of the remaining part, and swap it with position i if it is at a different position. How many swaps are made? ### Input The first line has n, the second line has n integers separated by spaces. ### Output A number.

Examples

Input
5
22 2 19 27 5
Output
3
Input
2
6 21
Output
0

💡 You can solve it with Python, JavaScript or blocks. Read the input line by line with input(). Don't print a question (like input("Number: ")). Print exactly what the output asks for, nothing more.

🔒 You can solve the first 3 problems without an account. Sign up for free to solve this one!