#include #include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(i, n) for (int i = (int)n - 1; i > -1; i--) #define all(x) (x).begin(), (x).end() #define ll long long #define ld long double #define INF 1000000000000000000 typedef pair pll; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector A(N); rep(i, N) { cin >> A[i]; } int ans = 0; vector points, spe; rep(i, N) { int cnt = 0; int cur = i; while (A[cur] == A[i] && cur < N) { cnt++; cur++; } points.push_back(cnt); if (cnt > 1) { spe.push_back(points.size() - 1); ans += cnt; } i = cur - 1; } if (spe.size() == 0) ans = (N / 2) + (N % 2); else { rep(i, spe.size()) { int diff; if (i == 0) { diff = max(0, spe[i] - 1); } else if (i == spe.size() - 1) { diff = max(0, (int)points.size() - spe[i] - 2); } else { diff = max(0, spe[i + 1] - spe[i] - 3); } ans += (diff / 2) + (diff % 2); } } cout << ans << endl; return 0; }