#include <bits/stdc++.h>
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define pii pair <int,int>
#define pll pair <ll,ll>
#define INF 1000000000
#define mod 1000000007
#define size(a) ((int)(a.size()))
using namespace std;
void solv()
{
int n;
cin>>n;
int t[n];
for(int i=0;i<n;i++)
{
cin>>t[i];
}
int ans=0;
int a=0,b=0;
for(int i=0;i<n;i++)
{
if(t[i]) a=1;
else b=1;
if(a&b)
{
ans++;
a=b=0;
}
}
cout<<ans<<endl;
}
int main()
{
quick
int TT=1; // cin>>TT;
while(TT--) solv();
return 0;
}
Copy