{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003e\n There is a complete graph containing $n$ vertices, the weight of the $i$-th vertex is $w_i$.\u003cbr\u003e\n The length of edge between vertex $i$ and $j$ $(i \\neq j)$ is $\\lfloor \\sqrt{|w_i - w_j|} \\rfloor$.\u003cbr\u003e\n Calculate the length of the shortest path from $1$ to $n$.\u003cbr\u003e\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of the input contains an integer $T$ $(1 \\le T \\le 10)$ denoting the number of test cases.\u003cbr\u003e\nEach test case starts with an integer $n$ $(1 \\le n \\le 10 ^ 5)$ denoting the number of vertices in the graph.\u003cbr\u003e\nThe second line contains $n$ integers, the $i$-th integer denotes $w_i$ $(1 \\le w_i \\le 10 ^ 5)$."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, print an integer denoting the length of the shortest path from $1$ to $n$.\u003cbr\u003e"}},{"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\u003e\u003cpre\u003e1\r\n3\r\n1 3 5\r\n\u003c/pre\u003e\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e\u003cpre\u003e2\u003c/pre\u003e\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}