#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef pair<ll, ll> pl;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define max(a, b) (a>b ? a : b)
#define min(a, b) (a<b ? a : b)
#define FAST ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)
const int N = int(1e6) + 3;
const int MOD = int(1e9) + 7;
int n;
ll a[N];
int main() {
FAST;
//freopen("easy", "r", stdin);
cin >> n;
for(int i=0;i<n-1;i++){
cin >> a[i];
if(a[i]!=0){
a[i]=2-a[i]%2;
}
}
int bef=a[0];
vector<int> v;
v.pb(a[0]);
for(int i=1;i<n-1;i++){
if(a[i]==bef){
continue;
}
v.pb(a[i]);
bef=a[i];
}
int res=0;
for(int i=1;i<v.size()-1;i++){
if(v[i]==0){
res++;
}
}
vector<int> vv;
for(int i=0;i<v.size();){
if(v[i]==1){
int j;
for(j=i;j<v.size();j++){
if(v[j]==0)
break;
}
vv.pb(j-i);
i=j;
}else{
i++;
}
}
for(auto u:vv){
res+=(u+1)/2 - 1 ;
}
cout << res << endl;
return 0;
}
Copy