#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n;
int a[N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  int last = a[0];
  int left = 0;
  set<tuple<int, int, int> > st, pos;
  for (int i = 0; i < n; ++i) {
    if (a[i] != last) {
      int sz = i - left;
      st.emplace(-sz, left, last);
      pos.emplace(left, sz, last);
      left = i;
      last = a[i];
    }
  }
  st.emplace(left - n, left, last);
  pos.emplace(left, n - left, last);
  int ans = 0;
  while ((int)st.size() > 0) {
    ans++;
    auto it = *st.begin();
    st.erase(st.begin());
    int sz, left, num;
    tie(sz, left, num) = it;
    auto it_pos = pos.lower_bound(make_tuple(left, sz, num));
    pos.erase(it_pos);
    if ((int)pos.size() < 2) continue;
    auto it_r = pos.upper_bound(make_tuple(left, 0, 0));
    if (it_r == pos.end() or it_r == pos.begin()) continue;
    int left_r, sz_r, num_r;
    tie(left_r, sz_r, num_r) = *it_r;
    auto it_l = prev(it_r);
    int left_l, sz_l, num_l;
    tie(left_l, sz_l, num_l) = *it_l;
    if (num_r == num_l) {
      pos.erase(it_r), pos.erase(it_l);
      pos.emplace(left_l, sz_l + sz_r, num_r);
      st.erase(st.find(make_tuple(-sz_r, left_r, num_r)));
      st.erase(st.find(make_tuple(-sz_l, left_l, num_l)));
      st.emplace(-(sz_r + sz_l), left_l, num_r);
    }
  }
  printf("%d\n", ans);
  return 0;
}
