#include <bits/stdc++.h>
using namespace std;
int n, x, cnt, pre, tot = 0;
int l[200010], r[200010], size;
bool vis[200100];
int col[200010], len[200010];
priority_queue<pair<int, int> > q;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    if (x == pre)
      cnt++;
    else {
      if (cnt != 0) {
        size++;
        col[size] = pre;
        l[size] = size - 1;
        len[size] = cnt;
        r[size - 1] = size;
        q.push(pair<int, int>(cnt, -size));
      }
      cnt = 1;
      pre = x;
    }
  }
  if (cnt != 0) {
    size++;
    col[size] = pre;
    len[size] = cnt;
    l[size] = size - 1;
    r[size - 1] = size;
    q.push(pair<int, int>(cnt, -size));
  }
  int ans = 0;
  while (tot < size) {
    ans++;
    int nw = -q.top().second;
    while (vis[nw]) {
      q.pop();
      nw = -q.top().second;
    }
    vis[nw] = 1;
    tot++;
    if ((!vis[l[nw]]) && (!vis[r[nw]]) && col[l[nw]] == col[r[nw]]) {
      vis[r[nw]] = 1;
      tot++;
      q.push(pair<int, int>(len[l[nw]] + len[r[nw]], -l[nw]));
      len[l[nw]] = len[l[nw]] + len[r[nw]];
      r[l[nw]] = r[r[nw]];
      l[r[r[nw]]] = l[nw];
    } else {
      r[l[nw]] = r[nw];
      l[r[nw]] = l[nw];
    }
  }
  printf("%d", ans);
}
