{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\u003cspan lang\u003d\"en-us\"\u003e\u003cp\u003eIn the new ACM-ICPC Regional Contest, a special monitoring and submitting system will be set up, and students will be able to compete at their own universities. However there’s one problem. Due to the high cost of the new judging system, the organizing committee can only afford to set the system up such that there will be only one way to transfer information from one university to another without passing the same university twice. The contestants will be divided into two connected regions, and the difference between the total numbers of students from two regions should be minimized. Can you help the juries to find the minimum difference?\u003c/p\u003e\u003c/span\u003e\u003c/div\u003e\n\n给你n个节点一棵树,树的每个节点都有一个权值,问你删掉一条边,使得分成的两棵树权值之和相差最小\u003cbr\u003e\n输入:多组输入,第一行n,m ,接下来一行n个点表示点权,接下来m行,每行两个ui,vi 表示之间有两边。当n\u003d0 and m\u003d0 输入结束"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\u003cspan lang\u003d\"en-us\"\u003e\u003cp\u003eThere are multiple test cases in the input file. Each test case starts with two integers \u003ci\u003eN\u003c/i\u003e and \u003ci\u003eM\u003c/i\u003e, (1 ≤ \u003ci\u003eN\u003c/i\u003e ≤ 100000, 1 ≤ \u003ci\u003eM\u003c/i\u003e ≤ 1000000), the number of universities and the number of direct communication line set up by the committee, respectively. Universities are numbered from 1 to \u003ci\u003eN\u003c/i\u003e. The next line has \u003ci\u003eN\u003c/i\u003e integers, the \u003ci\u003eK\u003c/i\u003e\u003csup\u003eth\u003c/sup\u003e integer is equal to the number of students in university numbered \u003ci\u003eK\u003c/i\u003e. The number of students in any university does not exceed 100000000. Each of the following \u003ci\u003eM\u003c/i\u003e lines has two integers \u003ci\u003es\u003c/i\u003e, \u003ci\u003et\u003c/i\u003e, and describes a communication line connecting university \u003ci\u003es\u003c/i\u003e and university \u003ci\u003et\u003c/i\u003e. All communication lines of this new system are bidirectional.\u003c/p\u003e\u003cp\u003e\u003ci\u003eN\u003c/i\u003e \u003d 0, \u003ci\u003eM\u003c/i\u003e \u003d 0 indicates the end of input and should not be processed by your program.\u003c/p\u003e\u003c/span\u003e\u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\u003cp\u003eFor every test case, output one integer, the minimum absolute difference of students between two regions in the format as indicated in the sample output.\u003c/p\u003e\u003c/div\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e7 6\n1 1 1 1 1 1 1\n1 2\n2 7\n3 7\n4 6\n6 2\n5 7\n0 0\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003eCase 1: 1\u003c/pre\u003e"}}]}