#include <bits/stdc++.h>
using namespace std;
int num[200005];
struct cmp {
  bool operator()(const pair<pair<int, int>, pair<int, int> > &a,
                  const pair<pair<int, int>, pair<int, int> > &b) const {
    return (a.second.first < b.second.first);
  }
};
set<pair<pair<int, int>, pair<int, int> >, cmp> st;
struct cmp2 {
  bool operator()(const pair<pair<int, int>, pair<int, int> > &a,
                  const pair<pair<int, int>, pair<int, int> > &b) const {
    if (a.first.second != b.first.second)
      return (a.first.second < b.first.second);
    else
      return (a.second.first > b.second.first);
  }
};
priority_queue<pair<pair<int, int>, pair<int, int> >,
               vector<pair<pair<int, int>, pair<int, int> > >, cmp2>
    pq;
int main() {
  int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q;
  scanf("%d", &a);
  for (i = 1; i <= a; i++) {
    scanf("%d", &num[i]);
  }
  for (i = 1; i <= a; i++) {
    if (i == 1 || num[i] != num[i - 1]) {
      if (i != 1) {
        st.insert({{num[i - 1], b}, {i - b, i - 1}});
        pq.push({{num[i - 1], b}, {i - b, i - 1}});
      }
      b = 1;
    } else {
      b++;
    }
  }
  st.insert({{num[a], b}, {a - b + 1, a}});
  pq.push({{num[a], b}, {a - b + 1, a}});
  int cnt = 0;
  while (!pq.empty()) {
    auto n = pq.top();
    pq.pop();
    auto it = st.find(n);
    if (it == st.end()) continue;
    cnt++;
    auto it3 = it;
    it3++;
    if (it != st.begin() && it3 != st.end()) {
      auto it2 = it;
      it2--;
      auto n2 = *it2, n3 = *it3;
      if (n2.first.first == n3.first.first) {
        pair<pair<int, int>, pair<int, int> > n4 = {
            {n2.first.first, n2.first.second + n3.first.second},
            {n2.second.first, n3.second.second}};
        st.erase(n2);
        st.erase(n3);
        st.insert(n4);
        pq.push(n4);
      }
    }
    st.erase(n);
  }
  printf("%d\n", cnt);
  return 0;
}
