#include <bits/stdc++.h>
using namespace std;
struct node {
  int num;
  int count;
  int idx;
  struct node *l, *r;
};
struct comp {
  bool operator()(const pair<pair<int, int>, node *> &f,
                  const pair<pair<int, int>, node *> &s) const {
    if (f.first.first > s.first.first) return true;
    if ((f.first.first == s.first.first) && (f.first.second < s.first.second))
      return true;
    return false;
  }
};
node *init(int val, int count, int idx) {
  node *temp = (node *)malloc(sizeof(node));
  temp->num = val;
  temp->count = count;
  temp->idx = idx;
  temp->l = temp->r = NULL;
  return temp;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, x, idx = 1;
  cin >> n;
  cin >> x;
  node *root = init(x, 1, idx);
  node *prev = root;
  set<pair<pair<int, int>, node *>, comp> st;
  for (int i = 1; i < n; i++) {
    cin >> x;
    if (x != prev->num) {
      node *temp = init(x, 1, ++idx);
      prev->r = temp;
      temp->l = prev;
      st.insert({{prev->count, prev->idx}, prev});
      prev = temp;
    } else
      prev->count++;
  }
  st.insert({{prev->count, prev->idx}, prev});
  int ans = 0;
  while (!st.empty()) {
    ans++;
    auto it = st.begin();
    node *ptr = it->second;
    st.erase(it);
    if (ptr->l && ptr->r) {
      if (ptr->l->num == ptr->r->num) {
        st.erase({{ptr->l->count, ptr->l->idx}, ptr->l});
        st.erase({{ptr->r->count, ptr->r->idx}, ptr->r});
        ptr->l->count += ptr->r->count;
        ptr->l->r = ptr->r->r;
        if (ptr->r->r) ptr->r->r->l = ptr->l;
        st.insert({{ptr->l->count, ptr->l->idx}, ptr->l});
        free(ptr->r);
      } else
        ptr->l->r = ptr->r, ptr->r->l = ptr->l;
    } else if (ptr->l)
      ptr->l->r = NULL;
    else if (ptr->r)
      ptr->r->l = NULL;
    free(ptr);
  }
  cout << ans << endl;
  return 0;
}
