{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e\nMiss Farzana, the president of Pandaland, has received the number of bamboos consumed by the pandas on each day since the formation of Pandaland. Due to the scarcity of bamboos, she has requested the pandas to reduce their bamboo consumption, even promising them rewards if they can do it. From \u003cb\u003eday 2\u003c/b\u003e she calculates the number of days prior to that day the pandas consumed less or equal amount of bamboos to that day. With the found numbers, she puts them in another list and calculates their sum.\n\u003c/p\u003e\n\u003cp\u003e\nFor example, let A \u003d (20, 43, 57, 43, 20) be the list of daily consumption amount. She will form another list B \u003d (b\u003csub\u003e1\u003c/sub\u003e, b\u003csub\u003e2\u003c/sub\u003e, b\u003csub\u003e3\u003c/sub\u003e, b\u003csub\u003e4\u003c/sub\u003e) from it. For the fourth day’s consumption amount, a\u003csub\u003e4\u003c/sub\u003e \u003d 43, the number of previous days whose sales amounts are less than or equal to it is 2 since a\u003csub\u003e1\u003c/sub\u003e ≤ a\u003csub\u003e4\u003c/sub\u003e, a\u003csub\u003e2\u003c/sub\u003e ≤ a\u003csub\u003e4\u003c/sub\u003e, and a\u003csub\u003e3\u003c/sub\u003e \u003e a\u003csub\u003e4\u003c/sub\u003e. Therefore, b\u003csub\u003e3\u003c/sub\u003e \u003d 2. Similarly, b\u003csub\u003e1\u003c/sub\u003e, b\u003csub\u003e2\u003c/sub\u003e and b\u003csub\u003e4\u003c/sub\u003e can be calcualted using similar measures. The formed list will be B \u003d (1, 2, 2, 1).\n\u003c/p\u003e\n\u003cp\u003e\nAs you are the best programmer in pandaland, Farzana turned to you for help. You\u0027re given the list A for n days and from it, you need to form B to calculate the sum of all the elements of B.\n\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003e\nYour program is to read the input from standard input. The input consists of T test cases. The number of test cases T is given in the first line of the input. Each test case starts with a line containing an integer n (2 ≤ n ≤ 1,000), which represents the size of list A . In the following line, n integers are given, each represents the daily consumption amount a\u003csub\u003ei\u003c/sub\u003e (1 ≤ a\u003csub\u003ei\u003c/sub\u003e ≤ 5,000 and 1 ≤ i ≤ n) for the test case.\n\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003e\nYour program is to write to standard output. For each test case, print the sum of the n − 1 integers in\nthe list B which is obtained from the list A.\nThe following shows sample input and output for two test cases.\n\u003c/p\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e\n2\n5\n38 111 102 111 177\n8\n276 284 103 439 452 276 452 398\n\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e\n9\n20\n\u003c/pre\u003e"}}]}