#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, ans;
struct Node {
  int val, p, cnt;
  int pre, nxt;
} a[N];
struct Comp {
  bool operator()(const pair<int, int> &x, const pair<int, int> &y) {
    return x.first == y.first ? x.second < y.second : x.first > y.first;
  }
};
set<pair<int, int>, Comp> st;
void solve() {
  scanf("%d", &n);
  int p = -1, k = 0;
  for (int i = 0; i < n; i++) {
    int tmp;
    scanf("%d", &tmp);
    if (tmp != k) {
      if (p != -1) a[p].nxt = i;
      a[i].pre = p;
      k = tmp;
      p = i;
      a[i].p = i;
      a[i].val = tmp;
      a[i].nxt = -1;
      a[i].cnt = 1;
    } else {
      a[p].cnt++;
    }
  }
  for (int i = 0; i < n; i++)
    if (a[i].cnt) st.insert(make_pair(a[i].cnt, i));
  while (!st.empty()) {
    auto it = st.begin();
    int pos = it->second;
    int pp = a[pos].pre, nn = a[pos].nxt;
    ans++;
    st.erase(it);
    if (pp != -1) a[pp].nxt = nn;
    if (nn != -1) a[nn].pre = pp;
    if (pp != -1 && nn != -1 && a[pp].val == a[nn].val) {
      int nnn = a[nn].nxt;
      a[nnn].pre = pp;
      a[pp].nxt = nnn;
      st.erase(st.find(make_pair(a[nn].cnt, nn)));
      st.erase(st.find(make_pair(a[pp].cnt, pp)));
      a[pp].cnt += a[nn].cnt;
      st.insert(make_pair(a[pp].cnt, pp));
    }
  }
  printf("%d\n", ans);
}
int main() {
  solve();
  return 0;
}
