#include using namespace std; #include using namespace atcoder; #define ll long long #define rep(i, n) for (int i = 0; i < (n); i++) #define P pair #define LP pair int main() { int n; cin >> n; vector a(n+1); rep(i,n) cin >> a[i]; a[n] = -1; vector b; int pre = a[0]; int cnt = 0; rep(i,n+1) { if (a[i] == pre) { cnt++; } else { b.push_back(cnt); cnt = 1; pre = a[i]; } } //rep(i,b.size()) cout << b[i] << endl; int ans = 0; bool used = false; rep(i,b.size()) { if (b[i] == 1) { if (!used) { ans += 1; used = true; } else { used = false; } } else { if (!used) { ans += b[i]; used = true; } else { ans += b[i]-1; } } } cout << ans << endl; }