L = gets.to_i
a = []
L.times do 
  a << gets.to_i
end


cost = 0
a.each do |n|
  cost += 1 if n.even? 
end

dp = []*(L+1)
dp[0] = 0
score = 0
minL = 0
L.times do |i|
  if a[i].odd?
    score += 1
  else
    score -= 1
  end
  minL = score if score < minL  
  dp[i+1] = minL
end

score = 0
minR = 0
min = 0
L.times do |i|
  k = L-1-i
  if a[k].odd?
    score += 1
  else
    score -= 1
  end
  minR = score if score < minR
  t = minR + dp[k]
  min = t if t < min
end

p cost + min
