import std.stdio;
import std.algorithm;

void main() {
  long l;
  readf("%d\n", &l);

  auto xs = new long[](l);
  foreach (i; 0..l) {
    long x;
    readf("%d\n", &x);

    xs[i] = x;
  }

  long s = 0;
  while (xs[s] == 0) { s++; }
  long e = l-1;
  while (xs[e] == 0) { e--; }

  long c = 0;
  long p = 0;
  for (long i = s; i <= e; i++) {
    if (i == s || xs[i] % 2 != p || xs[i] == 0) {
      c++;
      p = xs[i] % 2;
    }
  }
  writeln(max(c-3, 0));
}
