{"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":"Description","value":{"format":"MD","content":"Yakumo Ran is Yukari\u0027s shikigami. She will follow every command Yukari issues to her. \n\nToday Yukari gives Ran a set, and then issues $n$ commands. Commands will be of one of the three types:\n\n- `add x`, Yukari orders Ran to add $x$ to the set. It is guaranteed that $x$ was not in the set before this operation.\n- `del x`, Yukari orders Ran to delete $x$ from the set. It is guaranteed that $x$ was in the set before this operation.\n- `sum`, Yukari orders Ran to divide all elements into groups of five consecutive elements and find the median of each five. Then she asks Ran the sum of these medians.\nFormally speaking, for a sorted $k$-element set $S \u003d {a_1, a_2, \\ldots, a_k}$, where $a_1 \u003c a_2 \u003c a_3 \u003c \\ldots \u003c a_k$, the sum Yukari asks can be defined as\n$$\n\\sum^{i \\le k}_{i\\bmod 5 \u003d 3} a_i\n$$\n\nRespond to the commands as Ran."}},{"title":"Input","value":{"format":"MD","content":"\u003cp\u003eThe first line contains a 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 commands issued by Yukari.\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 commands: \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 sum Yukari requested as defined in Description. \u003c/li\u003e\u003c/ul\u003e\n\nIt is guaranteed that $1 \\le x \\le 10^9$ for `add` and `del` commands."}},{"title":"Output","value":{"format":"MD","content":"For each command of type `sum`, print the answer"}},{"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\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\nThe set after the `add` commands is $[1,2,\\color{red}3,4,5]$, the sum is $3$.\n"}},{"title":"Sample 2","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\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\nThe set right before the first `sum` command is $[1,2,\\color{red}5,7]$, the sum is $5$.\n\nThe set right before the second `sum` command is $[1,2,\\color{red}{3},4,5,6,7,\\color{red}8,9,10]$, the sum is $3+8\u003d11$.\n\nThe set right before the last `sum` command is $[2,3,\\color{red}4,5,6,7,8,\\color{red}9,10]$, the sum is $4+9\u003d13$."}}]}