CodeLab Academy 📞 9936 6696
← List Python · Level 7: Lists Code · 70 points ← #667 #669 →

#668. Swap the largest and the smallest

Swap the largest element (its first appearance) and the smallest element (its first appearance). ### Input The first line has n, the second line has n integers separated by spaces. ### Output One line.

Examples

Input
7
39 33 6 38 16 39 4
Output
4 33 6 38 16 39 39
Input
6
35 6 30 23 20 31
Output
6 35 30 23 20 31

💡 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!