#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, a[N], nxt[N], prv[N], ans;
pair<int, int> val[N];
set<pair<pair<int, int>, int> > S;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  int m = 0, cnt = 0;
  for (int i = 1; i <= n + 1; ++i) {
    if (a[i] != a[i - 1] && i > 1) {
      S.insert(make_pair(make_pair(-cnt, ++m), a[i - 1]));
      val[m] = make_pair(cnt, a[i - 1]);
      cnt = 0;
    }
    ++cnt;
  }
  for (int i = 1; i < m; ++i) nxt[i] = i + 1;
  for (int i = 2; i <= m; ++i) prv[i] = i - 1;
  while (!S.empty()) {
    ++ans;
    auto it = S.begin();
    int pos = it->first.second;
    S.erase(it);
    if (val[prv[pos]].first && val[nxt[pos]].first &&
        val[prv[pos]].second == val[nxt[pos]].second) {
      S.erase(make_pair(make_pair(-val[prv[pos]].first, prv[pos]),
                        val[prv[pos]].second));
      S.erase(make_pair(make_pair(-val[nxt[pos]].first, nxt[pos]),
                        val[nxt[pos]].second));
      nxt[prv[pos]] = nxt[nxt[pos]];
      prv[nxt[nxt[pos]]] = prv[pos];
      val[prv[pos]].first += val[nxt[pos]].first;
      S.insert(make_pair(make_pair(-val[prv[pos]].first, prv[pos]),
                         val[prv[pos]].second));
    } else {
      nxt[prv[pos]] = nxt[pos];
      prv[nxt[pos]] = prv[pos];
    }
  }
  cout << ans;
  return 0;
}
