#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <iomanip>
#include <fstream>
#include <chrono>
using namespace std;
int main()
{
int bits[100000];
int answer = 0;
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> bits[i];
}
for (int i = 0; i < n; i++)
{
if (bits[i] == 0)
{
while (i < n)
{
i++;
if (bits[i] == 1)
{
answer++;
break;
}
}
}
else if (bits[i] == 1)
{
while (i < n)
{
i++;
if (bits[i] == 0)
{
answer++;
break;
}
}
}
}
cout << answer << endl;
return 0;
}
Copy