#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353, N = 2e5 + 9;
int a[N];
int main() {
  int n, len = 1, ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  set<pair<int, int> > st1, st2, st3;
  for (int i = 2; i <= n + 1; ++i) {
    if (a[i] == a[i - 1]) {
      len++;
    } else {
      st1.insert({-1 * len, i - len});
      st2.insert({i - len, -1 * len});
      len = 1;
    }
  }
  set<pair<int, int> >::iterator it;
  while (!st1.empty()) {
    ans++;
    pair<int, int> p = *st1.begin();
    st1.erase(p);
    it = st2.lower_bound({p.second, p.first});
    if (it == st2.begin()) {
      st2.erase({p.second, p.first});
      continue;
    }
    it--;
    pair<int, int> p1 = (*it);
    it++;
    it++;
    if (it == st2.end()) {
      st2.erase({p.second, p.first});
      continue;
    }
    pair<int, int> p2 = (*it);
    st2.erase({p.second, p.first});
    if (a[p1.first] == a[p2.first]) {
      st2.erase(p1);
      st2.erase(p2);
      st2.insert({p1.first, p1.second + p2.second});
      st1.erase({p1.second, p1.first});
      st1.erase({p2.second, p2.first});
      st1.insert({p1.second + p2.second, p1.first});
    }
  }
  printf("%d\n", ans);
  return 0;
}
