#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, m = 0, a[N], b[N], num[N];
int nxt[N], last[N];
priority_queue<pair<int, int> > q;
set<pair<int, int> > s;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int cnt = 1;
  for (int i = 1; i <= n; i++) {
    if (a[i] == a[i + 1])
      cnt++;
    else
      b[++m] = cnt, num[m] = a[i], cnt = 1;
  }
  for (int i = 1; i <= m; i++)
    nxt[i] = i + 1, last[i] = i - 1, q.push(pair<int, int>(b[i], -i));
  int res = 0, x;
  while (m) {
    while (!q.empty() && s.count(q.top())) q.pop();
    x = -q.top().second, q.pop();
    int t1 = last[x], t2 = nxt[x];
    nxt[t1] = t2, last[t2] = t1;
    if (t1 && num[t1] == num[t2]) {
      s.insert(pair<int, int>(b[t1], -t1));
      s.insert(pair<int, int>(b[t2], -t2));
      b[t1] += b[t2];
      q.push(pair<int, int>(b[t1], -t1));
      nxt[t1] = nxt[t2];
      last[nxt[t2]] = t1;
      m--;
    }
    m--, res++;
  }
  cout << res << endl;
  return 0;
}
