{"trustable":true,"prependHtml":"\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eDreamGrid has an integer sequence $a_1, a_2, \\dots, a_n$ and he likes it very much. Unfortunately, his naughty roommate BaoBao swapped two elements $a_i$ and $a_j$ ($1 \\le i \u0026lt; j \\le n$) in the sequence when DreamGrid wasn\u0027t at home. When DreamGrid comes back, he finds with dismay that his precious sequence has been changed into $a_1, a_2, \\dots a_{i-1}, a_j, a_{i+1}, \\dots, a_{j-1}, a_i, a_{j+1}, \\dots, a_n$!\u003c/p\u003e\n\n\u003cp\u003eWhat\u0027s worse is that DreamGrid cannot remember his precious sequence. What he only remembers are the two values $x \u003d \\sum_{k\u003d1}^nka_k \\qquad \\text{and} \\qquad y \u003d \\sum_{k\u003d1}^nka_k^2$ Given the sequence after swapping and the two values DreamGrid remembers, please help DreamGrid count the number of possible element pairs $(a_i, a_j)$ BaoBao swaps.\u003c/p\u003e\n\n\u003cp\u003eNote that as DreamGrid is poor at memorizing numbers, the value of $x$ or $y$ might not match the sequence, and no possible element pair can be found in this situation.\u003c/p\u003e\n\n\u003cp\u003eTwo element pairs $(a_i, a_j)$ ($1 \\le i \u0026lt; j \\le n$) and $(a_p, a_q)$ ($1 \\le p \u0026lt; q \\le n$) are considered different if $i \\ne p$ or $j \\ne q$.\u003c/p\u003e\n\n\u003ch4\u003eInput\u003c/h4\u003e\n\u003cp\u003eThere are multiple test cases. The first line of the input contains an integer $T$, indicating the number of test cases. For each test case:\u003c/p\u003e\n\n\u003cp\u003eThe first line contains three integers $n$, $x$ and $y$ ($2 \\le n \\le 10^5, 1 \\le x, y \\le 10^{18}$), indicating the length of the sequence and the two values DreamGrid remembers.\u003c/p\u003e\n\n\u003cp\u003eThe second line contains $n$ integers $b_1, b_2, \\dots, b_n$ ($1 \\le b_i \\le 10^5$), indicating the sequence after swapping. It\u0027s guaranteed that $\\sum\\limits_{k\u003d1}^n kb_k \\le 10^{18}$ and $\\sum\\limits_{k\u003d1}^n kb_k^2 \\le 10^{18}$.\u003c/p\u003e\n\n\u003cp\u003eIt\u0027s guaranteed that the sum of $n$ of all test cases will not exceed $2 \\times 10^6$.\u003c/p\u003e\n\n\u003ch4\u003eOutput\u003c/h4\u003e\n\u003cp\u003eFor each test case output one line containing one integer, indicating the number of possible element pairs BaoBao swaps.\u003c/p\u003e\n\n\u003ch4\u003eSample\u003c/h4\u003e\n\u003ctable class\u003d\"vjudge_sample\"\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\u003e2\n6 61 237\n1 1 4 5 1 4\n3 20190429 92409102\n1 2 3\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\n0\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n\n\u003ch4\u003eHint\u003c/h4\u003e\n\u003cp\u003eFor the first sample test case, it’s possible that BaoBao swaps the 2nd and the 3rd element, or the 5th and the 6th element.\u003c/p\u003e\n"}}]}