#include<iostream>
using namespace std;
int main(){
register short n,cnt=0;
bool x;
cin>>n>>x;
while(--n){
	if(x){
		cin>>x;
		if(x){		cnt++;		x=0;	}
	}
	else	cin>>x;
}
cout<<cnt<<"\n";
return 0;
}