#include <bits/stdc++.h>
using namespace std;
struct tpl {
  int i, x, l;
  bool operator<(const tpl &e1) const { return (i < e1.i); }
};
struct tpl2 {
  int i, x, l;
  bool operator<(const tpl2 &e1) const {
    if (l == e1.l) return (i < e1.i);
    return (l > e1.l);
  }
};
int n, a[200001], cnt, sum;
vector<pair<int, int> > p;
multiset<tpl> s;
multiset<tpl>::iterator it, it1, it2;
multiset<tpl2> lar;
multiset<tpl2>::iterator it3;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  p.push_back({a[0], 1});
  for (int i = 1; i < n; i++) {
    if (a[i] == a[i - 1]) {
      p.back().second++;
    } else
      p.push_back({a[i], 1});
  }
  for (int i = 0; i < p.size(); i++) {
    s.insert({sum, p[i].first, p[i].second});
    sum += p[i].second;
  }
  for (auto &e : s) {
    lar.insert({e.i, e.x, e.l});
  }
  while (!s.empty()) {
    int i = lar.begin()->i, x = lar.begin()->x, l = lar.begin()->l;
    lar.erase(lar.begin());
    it = s.find({i, x, l});
    if (it != s.begin() and it != (--s.end())) {
      it1 = it;
      it1--;
      it2 = it;
      it2++;
      int len = it2->l;
      if ((it1->x) == (it2->x)) {
        it3 = lar.find({it1->i, it1->x, it1->l});
        lar.insert({it3->i, it3->x, (it3->l) + len});
        lar.erase(it3);
        lar.erase(lar.find({it2->i, it2->x, it2->l}));
        s.insert({it1->i, it1->x, (it1->l) + len});
        s.erase(it1);
        s.erase(it2);
      }
    }
    s.erase(s.find({i, x, l}));
    cnt++;
  }
  cout << cnt << '\n';
}
