#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
set<pair<int, int> > s;
struct {
  int data, pre, nex, cnt;
} a[N];
int tot, n;
void del(int p) {
  --tot;
  a[a[p].pre].nex = a[p].nex;
  a[a[p].nex].pre = a[p].pre;
  s.erase({-a[p].cnt, p});
}
int main() {
  scanf("%d", &n);
  tot = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[++tot].data);
    a[tot].cnt = 1;
    if (tot > 1 && a[tot].data == a[tot - 1].data) a[--tot].cnt++;
  }
  n = tot;
  for (int i = 1; i <= n; ++i) {
    a[i].pre = i - 1;
    a[i].nex = i + 1;
    s.insert({-a[i].cnt, i});
  }
  a[0].data = -1e9 - 10;
  a[n + 1].data = 1e9 + 10;
  int ans = 0;
  while (tot > 1) {
    ++ans;
    auto tmp = *(s.begin());
    int mid = tmp.second;
    int l = a[mid].pre, r = a[mid].nex;
    del(mid);
    if (a[l].data == a[r].data) {
      s.erase({-a[l].cnt, l});
      a[l].cnt += a[r].cnt;
      del(r);
      s.insert({-a[l].cnt, l});
    }
  }
  ans += tot;
  printf("%d\n", ans);
  return 0;
}
