{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003eIn this problem, you have to analyze a particular sorting algorithm. The BubbleSort 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 \n\u003cbr\u003e\u003ccenter\u003e9 1 0 5 4 , \u003c/center\u003e\n\u003cbr\u003eBubbleSort produces the output \n\u003cbr\u003e\u003ccenter\u003e0 1 4 5 9 . \u003c/center\u003e\n\u003cbr\u003eYour task is to determine how many swap operations BubbleSort needs to perform in order to sort a given input sequence. \u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003eThe 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.\u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003eFor every input sequence, your program prints a single line containing an integer number op, the number of swap operations necessary to sort the given input sequence.\u003c/div\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e5\n9\n1\n0\n5\n4\n\n3\n1\n2\n3\n\n0\n\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e6\n0\n\u003c/pre\u003e"}}]}