#include <bits/stdc++.h>
using namespace std;
struct state {
  int sz, l, r;
  state() {}
  state(int a, int b, int c) {
    sz = a;
    l = b;
    r = c;
  }
};
bool comp(state a, state b) {
  if (a.sz != b.sz) return a.sz > b.sz;
  return a.l < b.l;
}
set<state, bool (*)(state, state)> big(comp);
set<pair<int, int> > range;
map<pair<int, int>, int> len;
int n, v[201010];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  v[0] = -1;
  int l = 1, r;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    if (i > 1) {
      if (v[i] != v[i - 1]) {
        big.insert(state(i - 1 - l + 1, l, i - 1));
        range.insert(make_pair(l, i - 1));
        len[make_pair(l, i - 1)] = i - 1 - l + 1;
        l = i;
      }
    }
  }
  big.insert(state(n - l + 1, l, n));
  range.insert(make_pair(l, n));
  len[make_pair(l, n)] = n - l + 1;
  state maior;
  set<pair<int, int> >::iterator it, nxt, ant;
  int nwLen, nwL, nwR, aL, aR, nL, nR, len1, len2;
  int ans = 0;
  while ((int)range.size() > 1) {
    maior = *big.begin();
    big.erase(big.begin());
    ans++;
    l = maior.l;
    r = maior.r;
    it = range.find(make_pair(l, r));
    if (it == range.begin() || next(it) == range.end()) {
      range.erase(it);
      continue;
    }
    ant = prev(it);
    nxt = next(it);
    aL = ant->first;
    aR = ant->second;
    nL = nxt->first;
    nR = nxt->second;
    if (v[aR] != v[nL]) {
      range.erase(it);
      continue;
    }
    len1 = len[make_pair(aL, aR)];
    len2 = len[make_pair(nL, nR)];
    nwLen = len1 + len2;
    nwL = aL;
    nwR = nR;
    range.erase(make_pair(l, r));
    range.erase(make_pair(aL, aR));
    range.erase(make_pair(nL, nR));
    big.erase(state(len1, aL, aR));
    big.erase(state(len2, nL, nR));
    range.insert(make_pair(nwL, nwR));
    big.insert(state(nwLen, nwL, nwR));
    len[make_pair(nwL, nwR)] = nwLen;
  }
  cout << ans + 1 << "\n";
  return 0;
}
