{"trustable":false,"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\u003e\n Little D is really interested in the theorem of sets recently. There’s a problem that confused him a long time.\u0026nbsp;\u0026nbsp;\n \u003cbr\u003e Let T be a set of integers. Let the MIN be the minimum integer in T and MAX be the maximum, then the cost of set T if defined as (MAX - MIN)^2. Now given an integer set S, we want to find out M subsets \n \u003cspan\u003eS1\u003c/span\u003e, \n \u003cspan\u003eS2\u003c/span\u003e, …, SM of S, such that\n \u003cbr\u003e \n \u003cbr\u003e \n \u003cimg src\u003d\"CDN_BASE_URL/3dd1058b5d51c7f6e78982cdf3fbbd51\"\u003e \n \u003cbr\u003e \n \u003cbr\u003e and the total cost of each subset is minimal.\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003e The input contains multiple test cases.\u003cbr\u003e In the first line of the input there’s an integer T which is the number of test cases. Then the description of T test cases will be given.\u003cbr\u003e For any test case, the first line contains two integers N (≤ 10,000) and M (≤ 5,000). N is the number of elements in S (may be duplicated). M is the number of subsets that we want to get. In the next line, there will be N integers giving set S.\u003cbr\u003e \u003cbr\u003e \u0026nbsp;\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003e For each test case, output one line containing exactly one integer, the minimal total cost. Take a look at the sample output for format.\u003cbr\u003e \u003cbr\u003e \u0026nbsp;\u003c/p\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e\r\n2\r\n3 2\r\n1 2 4\r\n4 2\r\n4 7 10 1\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e\r\nCase 1: 1\r\nCase 2: 18\r\n\r\n\r\n\r\n \r\n \u003ci\u003e \u003c/i\u003e\u003c/pre\u003e"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cpre\u003e\r\n\u003c/pre\u003e \n\u003cdiv\u003e \n \u003cpre\u003e\r\n\t\u003c/pre\u003e \n \u003cdiv\u003e \n \u003cpre\u003e\r\n\t\t\u003cspan\u003eThe answer will fit into a 32-bit signed integer.\u003c/span\u003e\u003c/pre\u003e \n \u003c/div\u003e \n\u003c/div\u003e"}}]}