{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"Every year, Farmer John\u0027s N (1 \u0026lt;\u003d N \u0026lt;\u003d 20,000) cows attend \"MooFest\",a social gathering of cows from around the world. MooFest involves a variety of events including haybale stacking, fence jumping, pin the tail on the farmer, and of course, mooing. When the cows all stand in line for a particular event, they moo so loudly that the roar is practically deafening. After participating in this event year after year, some of the cows have in fact lost a bit of their hearing.\r\u003cbr\u003e\r\u003cbr\u003eEach cow i has an associated \"hearing\" threshold v(i) (in the range 1..20,000). If a cow moos to cow i, she must use a volume of at least v(i) times the distance between the two cows in order to be heard by cow i. If two cows i and j wish to converse, they must speak at a volume level equal to the distance between them times max(v(i),v(j)).\r\u003cbr\u003e\r\u003cbr\u003eSuppose each of the N cows is standing in a straight line (each cow at some unique x coordinate in the range 1..20,000), and every pair of cows is carrying on a conversation using the smallest possible volume.\r\u003cbr\u003e\r\u003cbr\u003eCompute the sum of all the volumes produced by all N(N-1)/2 pairs of mooing cows.\r\u003cbr\u003e"}},{"title":"Input","value":{"format":"HTML","content":"* Line 1: A single integer, N\r\u003cbr\u003e\r\u003cbr\u003e* Lines 2..N+1: Two integers: the volume threshold and x coordinate for a cow. Line 2 represents the first cow; line 3 represents the second cow; and so on. No two cows will stand at the same location.\r\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"* Line 1: A single line with a single integer that is the sum of all the volumes of the conversing cows.\r\u003cbr\u003e"}},{"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\u003e4\r\n3 1\r\n2 5\r\n2 6\r\n4 3\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e57\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}