#include <bits/stdc++.h>
using namespace std;
int a[200010];
int main() {
  int n;
  cin >> n;
  map<int, int> L;
  set<pair<int, int> > Q;
  set<pair<int, int> >::iterator rit;
  map<int, int>::iterator fit, bit;
  int p = 0, clen = 1, result = 0, ix, fx, bx;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i < n; i++) {
    if (a[i] == a[i - 1]) {
      clen++;
    } else {
      L[p] = clen;
      Q.insert(pair<int, int>(-clen, p));
      clen = 1;
      p = i;
    }
  }
  L[p] = clen;
  Q.insert(pair<int, int>(-clen, p));
  while (!L.empty()) {
    result++;
    rit = Q.begin();
    ix = rit->second;
    fit = ++L.find(ix);
    bit = --L.find(ix);
    L.erase(ix);
    Q.erase(rit);
    if (fit == L.end()) {
      continue;
    }
    if (bit == L.end()) {
      continue;
    }
    fx = fit->first;
    bx = bit->first;
    if (a[fx] != a[bx]) {
      continue;
    }
    Q.erase(pair<int, int>(-bit->second, bit->first));
    Q.erase(pair<int, int>(-fit->second, fit->first));
    Q.insert(pair<int, int>(-(L[fx] + L[bx]), bx));
    L[bx] += L[fx];
    L.erase(fx);
  }
  cout << result << endl;
  return 0;
}
