#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int N = 2e5 + 10;
int n, a[N], sum[N], res;
struct node {
  int len, id;
};
bool operator<(node a, node b) {
  return a.len == b.len ? a.id < b.id : a.len > b.len;
}
set<node> st;
set<int> s;
signed main() {
  cin >> n;
  s.insert(0);
  s.insert(n + 1);
  sum[n + 1] = -1;
  st.insert({0, 0});
  st.insert({0, 0});
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    if (a[i] == a[i - 1])
      sum[i] = sum[i - 1] + 1;
    else
      sum[i] = 1;
    if (a[i] != a[i + 1]) st.insert({sum[i], i}), s.insert(i);
  }
  while (1) {
    node u = *st.begin();
    if (u.len <= 0) break;
    st.erase(st.begin());
    res++;
    auto x = s.find(u.id);
    auto y = x;
    y++;
    x--;
    s.erase(u.id);
    if (a[*x] == a[*y]) {
      st.erase({sum[*x], *x});
      st.erase({sum[*y], *y});
      sum[*y] += sum[*x];
      s.erase(*x);
      st.insert({sum[*y], *y});
    }
  }
  cout << res << endl;
  return 0;
}
