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

#761. Number of inversions

Count the pairs with i < j and a[i] > a[j]. ### Input The first line has n, the second line has n integers separated by spaces. ### Output A number.

Examples

Input
13
20 0 1 15 17 9 19 2 0 19 20 0 7
Output
37
Input
11
16 12 5 11 10 1 4 6 18 18 19
Output
22

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