{"raw_statement":[{"iden":"problem statement","content":"Snuke stands on a number line. He has $L$ ears, and he will walk along the line continuously under the following conditions:\n\n*   He never visits a point with coordinate less than $0$, or a point with coordinate greater than $L$.\n*   He starts walking at a point with integer coordinate, and also finishes walking at a point with integer coordinate.\n*   He only changes direction at a point with integer coordinate.\n\nEach time when Snuke passes a point with coordinate $i-0.5$, where $i$ is an integer, he put a stone in his $i$\\-th ear.\nAfter Snuke finishes walking, Ringo will repeat the following operations in some order so that, for each $i$, Snuke's $i$\\-th ear contains $A_i$ stones:\n\n*   Put a stone in one of Snuke's ears.\n*   Remove a stone from one of Snuke's ears.\n\nFind the minimum number of operations required when Ringo can freely decide how Snuke walks."},{"iden":"constraints","content":"*   $1 \\leq L \\leq 2\\times 10^5$\n*   $0 \\leq A_i \\leq 10^9(1\\leq i\\leq L)$\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$L$\n$A_1$\n$:$\n$A_L$"},{"iden":"sample input 1","content":"4\n1\n0\n2\n3"},{"iden":"sample output 1","content":"1\n\nAssume that Snuke walks as follows:\n\n*   He starts walking at coordinate $3$ and finishes walking at coordinate $4$, visiting coordinates $3,4,3,2,3,4$ in this order.\n\nThen, Snuke's four ears will contain $0,0,2,3$ stones, respectively. Ringo can satisfy the requirement by putting one stone in the first ear."},{"iden":"sample input 2","content":"8\n2\n0\n0\n2\n1\n3\n4\n1"},{"iden":"sample output 2","content":"3"},{"iden":"sample input 3","content":"7\n314159265\n358979323\n846264338\n327950288\n419716939\n937510582\n0"},{"iden":"sample output 3","content":"1"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}