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

#757. Pairs with difference d

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

Examples

Input
15
10 2 1 3 2 4 3 0 4 10 9 2 2 10 4
5
Output
3
Input
10
3 3 7 4 10 8 2 10 5 9
2
Output
7

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