output_description: Print the minimum number of operations required when Ringo can freely decide
  how Snuke walks.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      L
      A_1
      :
      A_L
attempt: L, *A = map(int, open(0).read().split())
  a0 = a1 = a2 = a3 = a4 = 0
  rest = sum(A)
  P = [2, 1, 0]
  Q = [1, 0, 1]
  for a in A:
      b = (a - 1) % 2 + 1 if a else 0
      p = P[b]
      q = Q[b]
      a0 += a
      a1 = min(a0, a1 + p)
      a2 = min(a1, a2 + q)
      a3 = min(a2, a3 + p)
      a4 = min(a3, a4 + a)
  print(min(a0, a1, a2, a3, a4))
  
problem_description: Statement
  
  Snuke stands on a number line. He has L ears, and he will walk along the line
  continuously under the following conditions:
  
    * He never visits a point with coordinate less than 0, or a point with coordinate greater than L.
    * He starts walking at a point with integer coordinate, and also finishes walking at a point with integer coordinate.
    * He only changes direction at a point with integer coordinate.
  
  Each 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.
  
  After 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:
  
    * Put a stone in one of Snuke's ears.
    * Remove a stone from one of Snuke's ears.
  
  Find the minimum number of operations required when Ringo can freely decide
  how Snuke walks.
samples: [{"input": "4\n    1\n    0\n    2\n    3", "output": "1\n    \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\nsatisfy the requirement by putting one stone in the first ear.\n\n* * *"}, {"input": "8\n    2\n    0\n    0\n    2\n    1\n    3\n    4\n    1", "output": "3\n    \n\n* * *"}, {"input": "7\n    314159265\n    358979323\n    846264338\n    327950288\n    419716939\n    937510582\n    0", "output": "1"}]