#include <bits/stdc++.h>
using namespace std;
struct cmp {
  bool operator()(pair<int, int> a, pair<int, int> b) {
    if (a.second == b.second) return a.first < b.first;
    return a.second > b.second;
  }
};
int n, ans;
int a[200005], cd, s[200005], nr[200005], nl[200005], daloai[200005];
set<pair<int, int>, cmp> st;
void nhap() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[++cd]);
    s[cd]++;
    if (a[cd] == a[cd - 1]) {
      s[cd--]--;
      s[cd]++;
    }
  }
  for (int i = 1; i <= cd; i++) {
    st.insert(make_pair(i, s[i]));
    nl[i] = i;
    nr[i] = i;
  }
}
int nhaytrai(int u) {
  u = nl[u] - 1;
  if (daloai[u])
    return nhaytrai(u);
  else
    return u;
}
int nhayphai(int u) {
  u = nr[u] + 1;
  if (daloai[u])
    return nhayphai(u);
  else
    return u;
}
void gop(int u, int v) {
  st.erase(make_pair(u, s[u]));
  st.erase(make_pair(v, s[v]));
  s[u] += s[v];
  st.insert(make_pair(u, s[u]));
  daloai[v] = 1;
}
void solve() {
  while (!st.empty()) {
    pair<int, int> cur = *st.begin();
    st.erase(cur);
    ans++;
    int i = cur.first;
    daloai[i] = 1;
    int p = nhaytrai(i);
    int k = nhayphai(i);
    if (p > 0 && k <= cd && a[p] == a[k]) gop(p, k);
    nr[p] = k - 1;
    nl[k] = p + 1;
  }
}
int main() {
  nhap();
  solve();
  cout << ans;
  return 0;
}
