#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  int cnt = 1, c = 1;
  pair<int, int> p[200005];
  for (int i = 1; i < n; i++) {
    if (A[i] == A[i - 1]) {
      cnt++;
    } else {
      p[c++] = {cnt, A[i - 1]};
      cnt = 1;
    }
  }
  p[c++] = {cnt, A[n - 1]};
  set<pair<int, int>> st;
  vector<int> prv(c + 2), nxt(c + 2);
  prv[0] = 0;
  nxt[0] = 0;
  prv[c] = c;
  nxt[c] = c;
  for (int i = 1; i < c; i++) {
    prv[i] = i - 1;
    nxt[i] = i + 1;
    st.insert({-p[i].first, i});
  }
  int ans = 0;
  while ((int)st.size() > 0) {
    auto it = st.begin();
    if (prv[it->second] != 0 && nxt[it->second] != c) {
      if (p[prv[it->second]].second == p[nxt[it->second]].second) {
        auto it_p = st.find({-p[prv[it->second]].first, prv[it->second]});
        assert(it_p != it);
        st.erase(it_p);
        auto it_n = st.find({-p[nxt[it->second]].first, nxt[it->second]});
        assert(it_n != it);
        st.erase(it_n);
        p[prv[it->second]].first += p[nxt[it->second]].first;
        st.insert({-p[prv[it->second]].first, prv[it->second]});
        nxt[prv[it->second]] = nxt[nxt[it->second]];
        prv[nxt[nxt[it->second]]] = prv[it->second];
      } else {
        nxt[prv[it->second]] = nxt[it->second];
        prv[nxt[it->second]] = prv[it->second];
      }
    } else {
      nxt[prv[it->second]] = nxt[it->second];
      prv[nxt[it->second]] = prv[it->second];
    }
    st.erase(it);
    ans++;
  }
  cout << ans << "\n";
}
