import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array

main :: IO ()
main = do
  l <- readLn
  as <- replicateM l $ readLn :: IO [Int]
  -- print $ solve as
  print $ solve' l as

solve as = counts - (max 0 (hho - hhe)) - (max 0 (tho - the)) 
  where
    counts = foldr f 0 as
    f 0 acc = 1 + acc
    f i acc | i `mod` 2 == 0  = 1 + acc
            | otherwise       = acc

    (hho, hhe) = oe as
    (tho, the) = oe $ reverse as

    -- headOdd xs = length $ takeWhile odd xs
    oe xs = (headOdd, nextEven)
      where
        headOdd = length $ takeWhile odd xs
        nextEven = length $ takeWhile (\i -> (even i) && i == 0) $ drop headOdd xs


solve' l as = minimum $ map (\i -> dp!(l, i)) [0..4]
  where
    arr = listArray (1, l) as
    dp :: Array (Int, Int) Int
    dp = listArray ((0, 0), (l, 4)) $ map f [ (x,b) | x <- [0..l], b <- [0..4]]
    f :: (Int, Int) -> Int
    f (0, _) = 0
    f (i, choice) = case choice of
      0 -> leftIgnore + arr!i
      1 -> (minimum . take 2 $ choices) + if arr!i == 0 then 2 else if arr!i `mod` 2 == 0 then 0 else 1
      2 -> (minimum . take 3 $ choices) + if arr!i `mod` 2 == 0 then 1 else 0
      3 -> (minimum . take 4 $ choices) + if arr!i == 0 then 2 else if arr!i `mod` 2 == 0 then 0 else 1
      4 -> (minimum choices) + arr!i
      where
        leftIgnore = dp!(i-1, 0)
        leftFlap = dp!(i-1, 1)
        oneWay = dp!(i-1, 2)
        rightFlap = dp!(i-1, 3)
        rightIgnore = dp!(i-1, 4)
        choices = [leftIgnore, leftFlap, oneWay, rightFlap, rightIgnore]
