링크 : https://www.acmicpc.net/problem/15729
/*
문제 : 방탈출
링크 : https://www.acmicpc.net/problem/15729
*/
#include <iostream>
using namespace std;
int arr[1000000];
int main() {
int n;
int cnt = 0;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
for (int i = 0; i < n; i++) {
if (arr[i] == 1) {
cnt++;
if (arr[i+1] == 1) arr[i+1] = 0;
else arr[i+1] = 1;
if(arr[i+2] == 1) arr[i+2] = 0;
else arr[i+2] = 1;
}
}
cout << cnt;
return 0;
}