#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; #define int ll signed 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 = 0; rep(i, N)if (same[i])res++; if (!B.empty() && B.front() == N) { res += (B.front() + 1) / 2; B.pop_back(); } if (!same.back() && !B.empty()) { res += B.back() / 2; B.pop_back(); } if (!same.front() && !B.empty()) { reverse(B.begin(), B.end()); res += B.back() / 2; B.pop_back(); } for (int len : B) { res += (len - 1) / 2; } cout << res << endl; return 0; }