#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1);
const long long INFF = 1e18;
const int INF = 1e9 + 1;
const int mod = 1e9 + 7;
const int MAX = 2e5 + 7;
int ll[MAX], rr[MAX], siz[MAX], gp[MAX];
int fd(int v) { return gp[v] == v ? v : gp[v] = fd(gp[v]); }
void uni(int u, int v) {
  u = fd(u);
  v = fd(v);
  if (u == v) return;
  if (siz[u] > siz[v]) swap(u, v);
  siz[v] += siz[u];
  gp[u] = v;
  ll[v] = min(ll[v], ll[u]);
  rr[v] = max(rr[v], rr[u]);
  return;
}
int a[MAX];
bool ck[MAX];
set<pair<pair<int, int>, int>> st;
set<pair<int, int>> L, R;
int main(void) {
  int n;
  scanf("%d", &n);
  ;
  for (int i = (1); i < (n + 1); ++i) scanf("%d", a + i);
  for (int i = (1); i < (n + 1); ++i) siz[i] = 1, rr[i] = ll[i] = gp[i] = i;
  for (int i = (1); i < (n); ++i)
    if (a[i] == a[i + 1]) uni(i, i + 1);
  for (int i = (1); i < (n + 1); ++i) {
    int v = fd(i);
    if (!ck[v]) {
      ck[v] = 1;
      st.insert(make_pair(make_pair(siz[v], n - ll[v]), v));
      L.insert(make_pair(ll[v], v));
      R.insert(make_pair(rr[v], v));
    }
  }
  int ans = 0;
  while (!st.empty()) {
    ans++;
    auto it = --st.end();
    int v = it->second;
    auto l = L.lower_bound(make_pair(ll[v], v));
    auto r = R.lower_bound(make_pair(rr[v], v));
    if (l != L.begin() && ++r != R.end()) {
      l--;
      int v1 = l->second, v2 = r->second;
      if (a[ll[v1]] == a[ll[v2]]) {
        L.erase(*l);
        R.erase(*r);
        L.erase(make_pair(ll[v2], v2));
        R.erase(make_pair(rr[v1], v1));
        st.erase(make_pair(make_pair(siz[v1], n - ll[v1]), v1));
        st.erase(make_pair(make_pair(siz[v2], n - ll[v2]), v2));
        uni(v1, v2);
        v1 = fd(v1);
        st.insert(make_pair(make_pair(siz[v1], n - ll[v1]), v1));
        L.insert(make_pair(ll[v1], v1));
        R.insert(make_pair(rr[v1], v1));
      }
    }
    st.erase(*it);
    L.erase(make_pair(ll[v], v));
    R.erase(make_pair(rr[v], v));
  }
  printf("%d\n", ans);
  return 0;
}
