#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10, mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
struct node {
  int ch, l, r, sz, lb, rb, v;
  bool operator<(const node& b) const {
    if (sz == b.sz) return lb > b.lb;
    return sz < b.sz;
  }
};
node a[maxn];
priority_queue<node> q;
bool vis[maxn];
void check(node u) { printf("lb == %d rb == %d sz == %d\n", u.lb, u.rb, u.sz); }
void solve() {
  int ans = 0;
  while (!q.empty()) {
    node u = q.top();
    q.pop();
    if (vis[u.lb]) continue;
    ans++;
    int pos = u.lb;
    while (pos <= u.rb) vis[pos] = 1, pos = a[pos].r;
    node &le = a[a[u.lb].l], &ri = a[a[u.rb].r];
    le.r = a[u.rb].r;
    ri.l = a[u.lb].l;
    if (le.ch == ri.ch) {
      a[le.lb].rb = ri.rb;
      a[ri.rb].lb = le.lb;
      a[le.lb].sz = a[ri.rb].sz = a[ri.rb].sz + a[le.lb].sz;
      q.push(a[le.lb]);
    }
  }
  printf("%d\n", ans);
}
int main() {
  int n;
  scanf("%d", &n);
  a[0].ch = -INF;
  a[n + 1].ch = INF;
  for (int i = 0; i <= n + 1; i++) {
    if (i >= 1 && i <= n) scanf("%d", &a[i].ch);
    a[i].v = a[i].lb = a[i].rb = i;
    a[i].l = i - 1, a[i].r = i + 1;
    a[i].sz = 1;
  }
  for (int i = 2; i <= n; i++)
    if (a[i - 1].ch == a[i].ch) {
      a[a[i - 1].lb].rb = i;
      a[i].sz = ++a[a[i - 1].lb].sz;
      a[i].lb = a[i - 1].lb;
    }
  int temp = 1;
  while (temp <= n) {
    q.push(a[temp]);
    temp = a[temp].rb + 1;
  }
  solve();
  return 0;
}
