#include <bits/stdc++.h>
using namespace std;
struct P {
  int pos, len, l, r;
  P() { pos = len = l = r = 0; }
  bool operator<(const P& b) const {
    if (len == b.len)
      return pos > b.pos;
    else
      return len < b.len;
  }
} p[200010], b;
priority_queue<P> q;
bool vis[200010];
int a[200010];
int cnt, n, ans;
int main() {
  scanf("%d", &n);
  int x;
  a[0] = 1000000001;
  int len;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    if (a[cnt] == x)
      len++;
    else {
      if (cnt) {
        p[cnt].l = cnt - 1;
        p[cnt].r = cnt + 1;
        p[cnt].pos = cnt;
        p[cnt].len = len;
        q.push(p[cnt]);
        cnt++;
        len = 1;
        a[cnt] = x;
      } else {
        cnt++;
        len = 1;
        a[cnt] = x;
      }
    }
  }
  p[cnt].l = cnt - 1;
  p[cnt].r = cnt + 1;
  p[cnt].pos = cnt;
  p[cnt].len = len;
  q.push(p[cnt]);
  a[cnt + 1] = -a[0];
  while (!q.empty()) {
    b = q.top();
    q.pop();
    if (vis[b.pos]) continue;
    ans++;
    b.l = p[b.pos].l;
    b.r = p[b.pos].r;
    if (a[b.l] == a[b.r]) {
      a[b.pos] = a[b.l];
      vis[b.l] = vis[b.r] = 1;
      b.len = p[b.l].len + p[b.r].len;
      b.l = p[b.l].l;
      b.r = p[b.r].r;
      p[b.r].l = b.pos;
      p[b.l].r = b.pos;
      p[b.pos] = b;
      q.push(b);
    } else {
      p[b.r].l = b.l;
      p[b.l].r = b.r;
      vis[b.pos] = 1;
    }
  }
  cout << ans;
  return 0;
}
