#include <bits/stdc++.h>
using namespace std;
const int MX = 2000020;
priority_queue<pair<int, int> > pq;
int n, p, a[MX], S[MX], L[MX], lt[MX], rt[MX], ans, vis[MX];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0, j = 0; i < n; i = j) {
    for (;;) {
      j++;
      if (a[j] != a[i]) {
        break;
      }
    }
    S[++p] = a[i];
    L[p] = j - i;
    lt[p] = p - 1;
    rt[p] = p + 1;
    pq.push(make_pair(L[p], -p));
  }
  while (!pq.empty()) {
    int cnt = -pq.top().second;
    pq.pop();
    if (vis[cnt]) {
      continue;
    }
    vis[cnt] = 1;
    ans++;
    int x = lt[cnt], y = rt[cnt];
    lt[y] = x;
    rt[x] = y;
    if (lt[cnt] && S[x] == S[y]) {
      L[x] += L[y];
      vis[y] = 1;
      pq.push(make_pair(L[x], -x));
      x = lt[y];
      y = rt[y];
      lt[y] = x;
      rt[x] = y;
    }
  }
  cout << ans << endl;
  return 0;
}
