#include <bits/stdc++.h>
using namespace std;
struct group {
  int id, value, l, r, cnt, ll, rr;
  bool operator<(const group &a) const {
    if (cnt != a.cnt)
      return cnt < a.cnt;
    else
      return ll > a.ll;
  }
};
int n, arr[200010];
group g[200010];
int gnum;
bool deleted[200010];
int main() {
  int dnum = 0;
  memset(deleted, false, sizeof(deleted));
  scanf("%d", &n);
  scanf("%d", &arr[1]);
  gnum = 1;
  g[gnum].id = 1;
  g[gnum].value = arr[1];
  g[gnum].ll = 0;
  g[gnum].rr = 2;
  g[gnum].l = 1;
  g[gnum].r = 1;
  g[gnum].cnt = 1;
  for (int i = 2; i <= n; i++) {
    scanf("%d", &arr[i]);
    if (arr[i] != arr[i - 1]) {
      g[gnum].r = i - 1;
      g[gnum].cnt = i - g[gnum].l;
      g[++gnum].value = arr[i];
      g[gnum].id = gnum;
      g[gnum].l = i;
      g[gnum].r = i;
      g[gnum].cnt = 1;
      g[gnum].ll = gnum - 1;
      g[gnum].rr = gnum + 1;
    }
  }
  if (arr[n] == arr[n - 1]) {
    g[gnum].r = n;
    g[gnum].cnt = n - g[gnum].l + 1;
  }
  priority_queue<group> que;
  for (int i = 1; i <= gnum; i++) {
    que.push(g[i]);
  }
  while (!que.empty()) {
    group now = que.top();
    que.pop();
    int id = now.id;
    int ll = g[id].ll;
    int rr = g[id].rr;
    if (deleted[id])
      continue;
    else {
      dnum++;
      if (ll >= 1 && rr <= gnum && g[ll].value == g[rr].value) {
        g[id].cnt = g[ll].cnt + g[rr].cnt;
        g[id].ll = g[ll].ll;
        g[id].rr = g[rr].rr;
        g[id].value = g[ll].value;
        deleted[ll] = true;
        g[g[ll].ll].rr = id;
        deleted[rr] = true;
        g[g[rr].rr].ll = id;
        que.push(g[id]);
      } else {
        deleted[id] = true;
        g[ll].rr = rr;
        g[rr].ll = ll;
      }
    }
  }
  printf("%d\n", dnum);
  return 0;
}
