{"trustable":false,"prependHtml":"\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 async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"MD","content":"这次我们玩一个汉诺塔的变化版,现在把n个柱子围成一圈,要求每次可以把一个盘子移动到相邻的柱子上,所以每个柱子都有两个相邻的,不过为了简单,盘子都做成一样大小的。现在盘子有m个,`m\u003c\u003dn`,我们要做的,是让每个柱子上都不超过一个盘子"}},{"title":"Input","value":{"format":"MD","content":"多组输入,每组第一行是n,n是不大于500的正整数。接下来是n个正整数,表示每个柱子上分别有多少个盘子"}},{"title":"Output","value":{"format":"MD","content":"对于每组输入,输出最少移动步数"}},{"title":"Sample Input","value":{"format":"MD","content":"```\n10\n1 3 3 0 0 2 0 0 0 0\n```"}},{"title":"Sample Output","value":{"format":"MD","content":"```\n9\n```"}}]}