#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> A(n);
	rep(i, n) cin >> A[i];
	int ans1 = 0;
	vector<bool> elf;
	if (A[0] != A[1]) elf.push_back(true);
	else elf.push_back(false);
	for (int i = 1; i < n; ++i) {
		if (A[i] == A[i - 1]) {
			ans1++;
			elf[elf.size() - 1] = false;
		}
		else {
			elf.push_back(true);
		}
	}
	int ans = 0;
	rep(i, elf.size()) {
		if (!elf[i]) ans++;
	}
	//over3
	for (int i = 2; i < elf.size(); ++i) {
		if (elf[i - 2] && elf[i - 1] && elf[i]) {
			ans++;
			elf[i] = false;
		}
	}
	//edge2
	int k = elf.size();
	if (elf[0] && elf[1]) ans++;
	if (elf[k - 2] && elf[k - 1]) ans++;
	ans += ans1;
	cout << ans << endl;
	return 0;
}