#include <bits/stdc++.h>
using namespace std;
const int N = 400051;
int n;
int a[N];
int has[N];
struct px {
  int l, r, n, val, w;
} b[N];
priority_queue<px> st;
bool operator<(px a, px b) {
  return a.val < b.val || (a.val == b.val && a.n > b.n);
}
void solve() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int tot = 1, xtot = 0;
  for (int i = 2; i <= n + 1; i++) {
    if (a[i] != a[i - 1]) {
      b[++xtot].val = tot;
      b[xtot].l = xtot - 1;
      b[xtot].r = xtot + 1;
      b[xtot].n = xtot;
      b[xtot].w = a[i - 1];
      st.push(b[xtot]);
      tot = 1;
    } else
      tot++;
  }
  int ans = 0;
  b[0].w = -4;
  b[xtot + 1].w = -5;
  while (!st.empty()) {
    px t = st.top();
    st.pop();
    t = b[t.n];
    if (has[t.n] == 0) {
      ans++;
      if (b[t.l].w != b[t.r].w) {
        b[t.r].l = t.l;
        b[t.l].r = t.r;
        has[t.n] = 1;
      } else {
        has[t.l] = 1;
        has[t.r] = 1;
        b[b[t.r].r].l = t.n;
        b[b[t.l].l].r = t.n;
        t.val = b[t.l].val + b[t.r].val;
        t.w = b[t.l].w;
        t.l = b[t.l].l;
        t.r = b[t.r].r;
        b[t.n] = t;
        st.push(t);
      }
    }
  }
  printf("%d\n", ans);
}
int main() {
  int T;
  T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
