#include"bits/stdc++.h" using namespace std; #define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++) #define rep(i,n) REP((i),0,(n)) using ll = long long; int main() { int N; cin >> N; vector A(N), B; vector same(N, false); rep(i, N)cin >> A[i]; rep(i, N - 1) { if (A[i] == A[i + 1]) { same[i] = same[i + 1] = true; } } { int cnt = 0; rep(i, N) { if (same[i]) { if (cnt != 0)B.push_back(cnt); cnt = 0; } else { cnt++; } } if (cnt != 0)B.push_back(cnt); } int res = count(same.begin(), same.end(), true); if (!same.front() && !same.back() && B.size() == 1) { res += (B.front() + 1) / 2; B.pop_back(); } if (!same.front() && !B.empty()) { res += B.front() / 2; B.erase(B.begin()); } if (!same.back() && !B.empty()) { res += B.back() / 2; B.pop_back(); } for (int len : B) { res += (len - 1) / 2; } cout << res << endl; return 0; }