{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cstyle type\u003d\"text/css\"\u003e .sampledata { font-family: \"Courier New\", Courier, monospace; white-space: pre; }\u003c/style\u003e\"Never a borrower nor a lender be.\" O how Bessie wishes she had taken thatadvice! She has borrowed f\n\u003cbr\u003e rom or lent money to each of N (1 \u0026lt;\u003d N \u0026lt;\u003d100,000) friends, conveniently labeled 1..N.Payback day has\n\u003cbr\u003e \u0026nbsp;finally come. She knows she is owed more money thanshe owes to the other cows. They have all lined\u0026nbsp;\n\u003cbr\u003e up in a straightline, cow i standing i meters from the barn. Bessie is going totraverse the line col\n\u003cbr\u003e lecting money from those who owe her andreimbursing money to those she owes.As she moves down the li\n\u003cbr\u003e ne, she can request any cow who owes hermoney to give her the money. When she has enough money to pa\n\u003cbr\u003e y offany or all of her debts, she can pay the (recently collected) moneyto those she owes. Cow i owe\n\u003cbr\u003e s Bessie D_i money (-1,000 \u0026lt;\u003d D_i \u0026lt;\u003d1,000; D_i !\u003d 0). A negative debt means that Bessie owes money t\n\u003cbr\u003e othe cow instead of vice-versa.Bessie starts at the barn, location 0. What is the minimum distancesh\n\u003cbr\u003e e must travel to collect her money and pay all those she owes? Shemust end her travels at the end of\n\u003cbr\u003e \u0026nbsp;the line.\n\u003cbr\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cspan\u003e* Line 1: A single integer: N\u0026nbsp;\u003c/span\u003e\n\u003cbr\u003e \n\u003cspan\u003e* Lines 2..N+1: Line i+1 contains a single integer: D_i\u0026nbsp;\u003c/span\u003e\n\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"* Line 1: A single integer that is the total metric distance Bessie\u0026nbsp;\n\u003cbr\u003e must travel in order to collect or pay each cow.\u0026nbsp;\n\u003cbr\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cspan class\u003dsampledata\u003e5 \r\n100 \r\n-200 \r\n250 \r\n-200 \r\n200 \r\nINPUT DETAILS: \r\nThree cows owe Bessie; she owes two. When she\u0027s done, Bessie will have 150 \r\nmoney. \u003c/span\u003e\u003c/pre\u003e\u003ch2\u003eSample Output\u003c/h2\u003e\n\u003cpre class\u003dcontent\u003e\u003cspan class\u003dsampledata\u003e9 \u003c/span\u003e\u003c/pre\u003e\u003ch2\u003eHINT\u003c/h2\u003e\n\u003cdiv class\u003dcontent\u003e\u003cp\u003e\u003c/p\u003e\u003c/div\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cspan class\u003dsampledata\u003e9 \u003c/span\u003e\u003c/pre\u003e\u003ch2\u003eHINT\u003c/h2\u003e\n\u003cdiv class\u003dcontent\u003e\u003cp\u003e\u003c/p\u003e\u003c/div\u003e"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cp\u003e\u003c/p\u003e"}}]}