#include <bits/stdc++.h>
using namespace std;
set<pair<int, int> > a, b;
map<int, int> s;
int n, _, x, p, cnt, ans;
void rua(int i) {
  a.insert(make_pair(-cnt, p));
  b.insert(make_pair(p, _));
  s[p] = -cnt;
  p = i, _ = x, cnt = 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    if (x == _)
      cnt++;
    else if (i > 1)
      rua(i);
    else
      p = i, _ = x, cnt = 1;
  }
  rua(0);
  while (a.size() > 1) {
    ans++;
    int p = (*a.begin()).second;
    a.erase(*a.begin());
    auto i = b.lower_bound(make_pair(p, 0));
    b.erase(*i);
    i = b.lower_bound(make_pair(p, 233));
    if (i == b.begin() || i == b.end()) continue;
    pair<int, int> rua1 = *i;
    i--;
    pair<int, int> rua2 = *i;
    if (rua1.second != rua2.second) continue;
    pair<int, int> del1 = make_pair(s[rua1.first], rua1.first);
    pair<int, int> del2 = make_pair(s[rua2.first], rua2.first);
    a.erase(del1), a.erase(del2);
    a.insert(make_pair(del1.first + del2.first, del2.second));
    b.erase(rua1);
    s[rua2.first] = del1.first + del2.first;
  }
  printf("%d\n", ans + 1);
  return 0;
}
