{"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\"\u003eBesides on the traditional classes,Baby Volcano also needs to learn how to take the express mails.\u003cbr\u003e\u003cbr\u003eUsually express mails are stored in cabinets. In Baby Volcano\u0027s school,there are $n$ cabinets in a row,numbered by $1$ to $n$. The distance between two adjacent cabinets is $1$, and the entrance is at the cabinet $1$. Among all $n$ cabinets,the one numbered $k$ is special and it is used to enter the code and open the cabinet door.\u003cbr\u003e\u003cbr\u003eBaby Volcano has $m$ express mails to take,the $i$-th is in the cabinet $a_i$.\u003cbr\u003eTwo express mails will not be stored in the same cabinet. Also there is no express mail in the cabinet $k$.\u003cbr\u003e\u003cbr\u003eTo prevent expresses from being stolen, Baby Volcano have to take these express mails one by one, starting at the entrance. Generally, if he wants to take the express mail $i$, he have to walk to cabinet $k$ first to enter the code, and then walks to cabinet $a_i$. After taking the last one,he walks to the entrance.\u003cbr\u003e\u003cbr\u003eThere are so many express mails to take, so Baby Volcano wants to find a taking order which minimize the distance he walks.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line contains one integer $T(1 \\le T \\le 100)$,the number of testcases.\u003cbr\u003e\u003cbr\u003eFor each test cases,the first line contains three integer $n,m,k(1 \\le k \\le n \\le 10^9,1 \\le m \u0026lt; \\min(n,10^6))$\u003cbr\u003e\u003cbr\u003eThe next line contains $m$ integer,the $i$-th stand for $a_i(1 \\le a_i \\le n,a_i \\neq k)$.\u003cbr\u003e\u003cbr\u003eThe input guarantees that $\\sum m \\le 2 \\times 10^6$\u003cbr\u003e\u003cbr\u003e**Note:Because of the large input,it is prefered to use scanf instead of cin.**"}},{"title":"Output","value":{"format":"HTML","content":"For each test case,Output a single line contains one integer,representing for the minimal walking distance."}},{"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\u003e2\r\n10 2 5\r\n6 7\r\n10 2 5\r\n3 4\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e14\r\n10\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}