#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
set<pair<int, int> > pos, cnt;
int a[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int j;
  for (int i = 0; i < n; i = j) {
    j = i;
    while (j < n && a[i] == a[j]) j++;
    pos.insert(make_pair(i, j - i));
    cnt.insert(make_pair(-(j - i), i));
  }
  int ans = 0;
  while (!cnt.empty()) {
    pair<int, int> p = *cnt.begin();
    cnt.erase(cnt.begin());
    int idx = p.second;
    auto it = pos.lower_bound(make_pair(idx, 0));
    auto l = it, r = it;
    ans++;
    if (l != pos.begin()) {
      l--;
      r++;
      if (r != pos.end()) {
        int posL = (*l).first, posR = (*r).first, elementL = a[(*l).first],
            elementR = a[(*r).first], cntL = (*l).second, cntR = (*r).second;
        if (elementL == elementR) {
          pos.erase(l);
          pos.erase(r);
          pos.insert(make_pair(posL, cntL + cntR));
          cnt.erase(make_pair(-cntL, posL));
          cnt.erase(make_pair(-cntR, posR));
          cnt.insert(make_pair(-(cntL + cntR), posL));
        }
      }
    }
    pos.erase(it);
  }
  printf("%d\n", ans);
  return 0;
}
