{"trustable":true,"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":"\u003cp\u003eIn one well-known algorithm of finding the \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ek\u003c/i\u003e\u003c/span\u003e-th order statistics we should divide all elements into groups of five consecutive elements and find the median of each five. A median is called the middle element of a sorted array (it\u0027s the third largest element for a group of five). To increase the algorithm\u0027s performance speed on a modern video card, you should be able to find a sum of medians in each five of the array.\u003c/p\u003e\u003cp\u003eA \u003cspan class\u003d\"tex-font-style-it\"\u003esum of medians\u003c/span\u003e of a sorted \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ek\u003c/i\u003e\u003c/span\u003e-element set \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eS\u003c/i\u003e \u003d {\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\u003ek\u003c/i\u003e\u003c/sub\u003e}\u003c/span\u003e, where \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ea\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e1\u003c/sub\u003e \u0026lt; \u003ci\u003ea\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e2\u003c/sub\u003e \u0026lt; \u003ci\u003ea\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e3\u003c/sub\u003e \u0026lt; ... \u0026lt; \u003ci\u003ea\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ek\u003c/i\u003e\u003c/sub\u003e\u003c/span\u003e, will be understood by as \u003c/p\u003e\u003ccenter class\u003d\"tex-equation\"\u003e\u003cimg align\u003d\"middle\" class\u003d\"tex-formula\" src\u003d\"CDN_BASE_URL/392817eb6a8143eadbd75e56a4a63efe?v\u003d1726584529\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e\u003c/center\u003e\u003cp\u003eThe \u003cimg align\u003d\"middle\" class\u003d\"tex-formula\" src\u003d\"CDN_BASE_URL/b8c78f21c5527b93c9b61dc41db14d6e?v\u003d1726584529\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e operator stands for taking the remainder, that is \u003cimg align\u003d\"middle\" class\u003d\"tex-formula\" src\u003d\"CDN_BASE_URL/c475ae6063f32ba2dd57c62d69e8985f?v\u003d1726584529\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e stands for the remainder of dividing \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ex\u003c/i\u003e\u003c/span\u003e by \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ey\u003c/i\u003e\u003c/span\u003e.\u003c/p\u003e\u003cp\u003eTo organize exercise testing quickly calculating \u003cspan class\u003d\"tex-font-style-it\"\u003ethe sum of medians\u003c/span\u003e for a changing set was needed.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains number \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003en\u003c/i\u003e\u003c/span\u003e (\u003cspan class\u003d\"tex-span\"\u003e1 ≤ \u003ci\u003en\u003c/i\u003e ≤ 10\u003csup class\u003d\"upper-index\"\u003e5\u003c/sup\u003e\u003c/span\u003e), the number of operations performed.\u003c/p\u003e\u003cp\u003eThen each of \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003en\u003c/i\u003e\u003c/span\u003e lines contains the description of one of the three operations: \u003c/p\u003e\u003cul\u003e \u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003eadd \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ex\u003c/i\u003e\u003c/span\u003e\u003c/span\u003e\u0026nbsp;— add the element \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ex\u003c/i\u003e\u003c/span\u003e to the set; \u003c/li\u003e\u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003edel \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ex\u003c/i\u003e\u003c/span\u003e\u003c/span\u003e\u0026nbsp;— delete the element \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ex\u003c/i\u003e\u003c/span\u003e from the set; \u003c/li\u003e\u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003esum\u003c/span\u003e\u0026nbsp;— find the \u003cspan class\u003d\"tex-font-style-it\"\u003esum of medians\u003c/span\u003e of the set. \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eFor any \u003cspan class\u003d\"tex-font-style-tt\"\u003eadd \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ex\u003c/i\u003e\u003c/span\u003e\u003c/span\u003e operation it is true that the element \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ex\u003c/i\u003e\u003c/span\u003e is not included in the set directly before the operation.\u003c/p\u003e\u003cp\u003eFor any \u003cspan class\u003d\"tex-font-style-tt\"\u003edel \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ex\u003c/i\u003e\u003c/span\u003e\u003c/span\u003e operation it is true that the element \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ex\u003c/i\u003e\u003c/span\u003e is included in the set directly before the operation.\u003c/p\u003e\u003cp\u003eAll the numbers in the input are positive integers, not exceeding \u003cspan class\u003d\"tex-span\"\u003e10\u003csup class\u003d\"upper-index\"\u003e9\u003c/sup\u003e\u003c/span\u003e.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each operation \u003cspan class\u003d\"tex-font-style-tt\"\u003esum\u003c/span\u003e print on the single line \u003cspan class\u003d\"tex-font-style-it\"\u003ethe sum of medians\u003c/span\u003e of the current set. If the set is empty, print 0.\u003c/p\u003e\u003cp\u003ePlease, do not use the \u003cspan class\u003d\"tex-font-style-tt\"\u003e%lld\u003c/span\u003e specificator to read or write 64-bit integers in C++. It is preferred to use the \u003cspan class\u003d\"tex-font-style-tt\"\u003ecin\u003c/span\u003e, \u003cspan class\u003d\"tex-font-style-tt\"\u003ecout\u003c/span\u003e streams (also you may use the \u003cspan class\u003d\"tex-font-style-tt\"\u003e%I64d\u003c/span\u003e specificator).\u003c/p\u003e"}},{"title":"Examples","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\u003e6\nadd 4\nadd 5\nadd 1\nadd 2\nadd 3\nsum\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"","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\u003e14\nadd 1\nadd 7\nadd 2\nadd 5\nsum\nadd 6\nadd 8\nadd 9\nadd 3\nadd 4\nadd 10\nsum\ndel 1\nsum\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5\n11\n13\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}