{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cimg src\u003d\"CDN_BASE_URL/b3530eaa8fa98ef394d3639722240a8c?v\u003d1715628207\" align\u003d\"right\"\u003eIn this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence elements until the sequence is sorted in ascending order. For the input sequence \r\u003cbr\u003e\u003ccenter\u003e9 1 0 5 4 , \u003c/center\u003e\r\u003cbr\u003eUltra-QuickSort produces the output \r\u003cbr\u003e\u003ccenter\u003e0 1 4 5 9 . \u003c/center\u003e\r\u003cbr\u003eYour task is to determine how many swap operations Ultra-QuickSort needs to perform in order to sort a given input sequence. "}},{"title":"Input","value":{"format":"HTML","content":"The input contains several test cases. Every test case begins with a line that contains a single integer n \u0026lt; 500,000 -- the length of the input sequence. Each of the the following n lines contains a single integer 0 ≤ a[i] ≤ 999,999,999, the i-th input sequence element. Input is terminated by a sequence of length n \u003d 0. This sequence must not be processed."}},{"title":"Output","value":{"format":"HTML","content":"For every input sequence, your program prints a single line containing an integer number op, the minimum number of swap operations necessary to sort the given input sequence."}},{"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\u003e5\r\n9\r\n1\r\n0\r\n5\r\n4\r\n3\r\n1\r\n2\r\n3\r\n0\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e6\r\n0\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}