#include <bits/stdc++.h>
const int N = 222222;
using namespace std;
int a[N];
int main() {
  set<pair<int, int> > st, q;
  set<pair<int, int> >::iterator it1, it2;
  int n;
  int cur = 1;
  int ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 2; i <= n; i++) {
    if (a[i] != a[i - 1]) {
      st.insert(make_pair(i - cur, -cur));
      q.insert(make_pair(cur, i - cur));
      cur = i;
    }
  }
  st.insert(make_pair(n + 1 - cur, -cur));
  q.insert(make_pair(cur, n + 1 - cur));
  while (!st.empty()) {
    ++ans;
    it1 = st.end();
    it1--;
    int id1 = -1, id2 = -1, len1 = 0, len2 = 0;
    int val = (*it1).first, pos = -(*it1).second;
    q.erase(make_pair(pos, val));
    st.erase(make_pair(val, -pos));
    it2 = q.lower_bound(make_pair(pos, 0));
    if (it2 == q.end() || it2 == q.begin()) {
      continue;
    }
    id2 = (*it2).first;
    len2 = (*it2).second;
    it2--;
    id1 = (*it2).first;
    len1 = (*it2).second;
    int tot = len1 + len2;
    if (a[id1] == a[id2]) {
      q.erase(make_pair(id1, len1));
      q.erase(make_pair(id2, len2));
      st.erase(make_pair(len1, -id1));
      st.erase(make_pair(len2, -id2));
      q.insert(make_pair(id1, tot));
      st.insert(make_pair(tot, -id1));
    }
  }
  printf("%d\n", ans);
}
