{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eChika gives you an integer sequence $a_1, a_2, \\ldots, a_n$ and $m$ tasks. For each task, you need to answer the number of \"\u003cb\u003efriendly pairs\u003c/b\u003e\" in a given interval.\u003cbr\u003e\u003cbr\u003e\u003cb\u003efriendly pair\u003c/b\u003e: for two integers $a_i$ and $a_j$, if $i\u0026lt;j$ and the absolute value of $a_i-a_j$ is no more than a given constant integer $K$, then $(i, j)$ is called a \"friendly pair\".A friendly pair $(i, j)$ in a interval $[L,R]$ should satisfy $L \\leq i \u0026lt; j \\leq R$.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line contains $3$ integers $n$ $(1 \\leq n \\leq 27000)$, $m$ $(1 \\leq m \\leq 27000)$ and $K$ $(1 \\leq K \\leq 10^9)$, representing the number of integers in the sequence $a$, the number of tasks and the given constant integer.\u003cbr\u003eThe second line contains $n$ non-negative integers, representing the integers in the sequence $a$. Every integer of sequence $a$ is no more than $10^9$.\u003cbr\u003eThen $m$ lines follow, each of which contains two integers $L$, $R$ $(1 \\leq L \\leq R \\leq n)$. The meaning is to ask the number of \"friendly pairs\" in the interval $[L,R]$。"}},{"title":"Output","value":{"format":"HTML","content":"For each task, you need to print one line, including only one integer, representing the number of \"friendly pairs\" in the query interval."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e7 5 3\r\n2 5 7 5 1 5 6\r\n6 6\r\n1 3\r\n4 6\r\n2 4\r\n3 4\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\r\n2\r\n1\r\n3\r\n1\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}