{"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\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cstyle type\u003d\u0027text/css\u0027\u003e .input, .output {border: 1px solid #888888;} .output {margin-bottom:1em;position:relative;top:-1px;} .output pre,.input pre {background-color:#EFEFEF;line-height:1.25em;margin:0;padding:0.25em;} .title {background-color:#FFFFFF;border-bottom: 1px solid #888888;font-family:arial;font-weight:bold;padding:0.25em;} \u003c/style\u003e \u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027]], displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027]]}\n });\n \u003c/script\u003e\n \u003cscript type\u003d\"text/javascript\" async\n src\u003d\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\"\u003e\n \u003c/script\u003e\n\u003cp\u003eRamana is the principal of Vasavi School. Since its saturday, Ramana ordered all \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003en\u003c/i\u003e\u003c/span\u003e students to line up on the ground for assembly.\u003c/p\u003e\n\u003cp\u003eAccording to assembly rules the students should stand in the order of non-increasing of their height. But as there\u0027s virtually no time to do that, the students lined up in the arbitrary order. However, Ramana is rather short-sighted and he thinks that the students lined up correctly if the first student in the line has the \u003cb\u003emaximum\u003c/b\u003e height and the last student has the \u003cb\u003eminimum\u003c/b\u003e height. Please note that the way other student are positioned does not matter, including the case when there are several students whose height is maximum or minimum. Only the heights of the \u003cspan class\u003d\"tex-font-style-bf\"\u003efirst\u003c/span\u003e and the \u003cspan class\u003d\"tex-font-style-bf\"\u003elast\u003c/span\u003e students are important.\u003c/p\u003e\n\u003cp\u003eFor example, Ramana considers the sequence of heights \u003cspan class\u003d\"tex-font-style-tt\"\u003e(4, 3, 4, 2, 1, 1)\u003c/span\u003e correct and the sequence \u003cspan class\u003d\"tex-font-style-tt\"\u003e(4, 3, 1, 2, 2)\u003c/span\u003e wrong.\u003c/p\u003e\n\u003cp\u003eWithin one second any two neighboring students can be swapped. What is the minimum time needed to form a line-up which Ramana will consider correct.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first input line contains the only integer \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003en\u003c/i\u003e\u003c/span\u003e (\u003cspan class\u003d\"tex-span\"\u003e2 ≤ \u003ci\u003en\u003c/i\u003e ≤ 100\u003c/span\u003e) which represents the number of students in the line. The second line contains integers \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ea\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e1\u003c/sub\u003e, \u003ci\u003ea\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e2\u003c/sub\u003e, ..., \u003ci\u003ea\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003en\u003c/i\u003e\u003c/sub\u003e\u003c/span\u003e (\u003cspan class\u003d\"tex-span\"\u003e1 ≤ \u003ci\u003ea\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e ≤ 100\u003c/span\u003e) the values of the students heights in the order of students heights\u0027 increasing in the order from the beginning of the line to its end. The numbers are space-separated. Numbers \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ea\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e1\u003c/sub\u003e, \u003ci\u003ea\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e2\u003c/sub\u003e, ..., \u003ci\u003ea\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003en\u003c/i\u003e\u003c/sub\u003e\u003c/span\u003e are not necessarily different.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003ePrint the only integer — the minimum number of seconds required to form the line-up that Ramana will consider correct.\u003c/p\u003e"}},{"title":"Examples","value":{"format":"HTML","content":"\u003cdiv class\u003d\"sample-test\"\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e4\u003cbr\u003e33 44 11 22\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e2\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e7\u003cbr\u003e10 10 58 31 63 40 76\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e10\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n\u003c/div\u003e"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the first sample the we will need to swap the first and second student and then the third and fourth student. That will take 2 seconds. The resulting position of the students is \u003cspan class\u003d\"tex-font-style-tt\"\u003e(44, 33, 22, 11)\u003c/span\u003e.\u003c/p\u003e\n\u003cp\u003eIn the second sample the we may swap the students in the following sequence:\u003c/p\u003e\n\u003col\u003e \n \u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003e(10, 10, 58, 31, 63, 40, 76)\u003c/span\u003e \u003c/li\u003e\n \u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003e(10, 58, 10, 31, 63, 40, 76)\u003c/span\u003e \u003c/li\u003e\n \u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003e(10, 58, 10, 31, 63, 76, 40)\u003c/span\u003e \u003c/li\u003e\n \u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003e(10, 58, 10, 31, 76, 63, 40)\u003c/span\u003e \u003c/li\u003e\n \u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003e(10, 58, 31, 10, 76, 63, 40)\u003c/span\u003e \u003c/li\u003e\n \u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003e(10, 58, 31, 76, 10, 63, 40)\u003c/span\u003e \u003c/li\u003e\n \u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003e(10, 58, 31, 76, 63, 10, 40)\u003c/span\u003e \u003c/li\u003e\n \u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003e(10, 58, 76, 31, 63, 10, 40)\u003c/span\u003e \u003c/li\u003e\n \u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003e(10, 76, 58, 31, 63, 10, 40)\u003c/span\u003e \u003c/li\u003e\n \u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003e(76, 10, 58, 31, 63, 10, 40)\u003c/span\u003e \u003c/li\u003e\n \u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003e(76, 10, 58, 31, 63, 40, 10)\u003c/span\u003e \u003c/li\u003e\n\u003c/ol\u003e"}}]}