{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"MD","content":"There are $n$ presons playing Hearthstone$Π$.They like to play Quilboar(野猪人).\n\n\u0026emsp;\u0026emsp;\u0026emsp;\u0026emsp;\u0026emsp;\u0026emsp;\u0026emsp;\u0026emsp;\u0026emsp;\u0026emsp;\u0026emsp;\u0026emsp;\u0026emsp;![873C1EC1F44C82807C82891CE7394983.png](https://s2.loli.net/2022/08/19/rsCwZLH2Sp7bMP4.jpg)\n\nIn Hearthstone,Quilboar usually can produce Blood Gems,which let heroes increase the health and attack power.But in Hearthstones$Π$,Every Quilboar has $a$(their attribute) and $v$(the production speed of blood gems)\n\u003cp\u003e\u003cspan class\u003d\"tex-font-style-bf\"\u003enote:the speed can be negative integer,means lose a blood gem.\u003c/span\u003e\u003c/p\u003e\n\u003cp\u003eWhen Quilboar makes a blood gem, he will use gems to increase his attribute to 1 (\u003cspan class\u003d\"tex-font-style-bf\"\u003enote: the time can be non-integer, as long as he makes a gem, it can be used\u003c/span\u003e), Of course,lose a blood gem,he will be decrease attribute to 1(attribute can be negative integer).The $i$-th preson\u0027s Quilboar has $a_i$ initial attribute and $v_i$ production speed,So every Quilboar\u0027s attribute in time $t$ will be $a_i$+$v_i$$*$$t$(t \u003cspan class\u003d\"tex-font-style-bf\"\u003ecan be non-integer\u003c/span\u003e).For each two presons,they may fight at any time(can be zero),So they want to know the minimum difference between their attributes and others, so please calculate the sum of the minimum difference between each two people.\u003c/p\u003e\n\u003cp\u003ewe define the difference of person A and person B is the absolute value of the attribute of A minus the attribute of B in the fight time,in other words,the difference $d$ \u003d $|$$a_A$-$a_B$$|$($a_A$and$a_B$is the attribute of A and B in same time).\u003c/p\u003e"}},{"title":"Input","value":{"format":"MD","content":"\u003cp\u003eThe first line of the input contains one integer $$$n$$$ ($$$2 \\le n \\le 2 \\cdot 10^5$$$) — the number of presons.\u003c/p\u003e\n\u003cp\u003eThe second line of the input contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 10^8$$$), where $$$a_i$$$ is the initial attribute of the $$$i$$$-th preson\u0027s Quilboar. It is guaranteed that all $$$a_i$$$ are distinct.\u003c/p\u003e\n\u003cp\u003eThe third line of the input contains $$$n$$$ integers $$$v_1, v_2, \\dots, v_n$$$ ($$$-10^8 \\le v_i \\le 10^8$$$), where $$$v_i$$$ is the production speed of the $$$i$$$-th person\u0027s Quilboar.\u003c/p\u003e"}},{"title":"Output","value":{"format":"MD","content":"\u003cp\u003ePrint one integer — the sum of minimum differences over all pairs of persons.\u003c/p\u003e"}},{"title":"Sample 1","value":{"format":"MD","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\n11 4 5 14\n19 19 8 10\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e22\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}