#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
const int inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
int n, a[maxn], tp, b[maxn], c[maxn], l[maxn], r[maxn], ch[maxn], ans;
struct mmp {
  int len, id;
  bool operator<(const mmp &op) const {
    if (len == op.len)
      return id > op.id;
    else
      return len < op.len;
  }
} p;
priority_queue<mmp> pq;
int main() {
  int i, j, x, y, id;
  cin >> n;
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= n; i++) {
    j = i;
    while (j <= n && a[j] == a[i]) j++;
    b[++tp] = a[i];
    c[tp] = j - i;
    l[tp] = tp - 1;
    r[tp] = tp + 1;
    p.id = tp;
    p.len = j - i;
    pq.push(p);
    i = j - 1;
  }
  while (!pq.empty()) {
    p = pq.top();
    pq.pop();
    id = p.id;
    if (ch[id]) continue;
    ans++;
    ch[id] = 1;
    x = l[id];
    y = r[id];
    r[x] = y;
    l[y] = x;
    if (x && y && b[x] == b[y]) {
      c[x] += c[y];
      p.len = c[x];
      p.id = x;
      pq.push(p);
      ch[y] = 1;
      r[x] = r[y];
      l[r[y]] = x;
    }
  }
  cout << ans << "\n";
  return 0;
}
