#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
const int INF = 0x3f3f3f3f;
set<pair<int, int> > st1, st2;
int mp[200005];
int a[200005];
int main() {
  int ans = 0;
  int n, k = 1, i;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] != a[k]) {
      st1.insert(make_pair(k - i, k));
      st2.insert(make_pair(k, k - i));
      k = i;
    }
  }
  st1.insert(make_pair(k - i, k));
  st2.insert(make_pair(k, k - i));
  while (st1.size() > 1) {
    ans++;
    set<pair<int, int> >::iterator it = st1.begin();
    int q = it->second;
    int q2 = it->first;
    set<pair<int, int> >::iterator it2 = st2.lower_bound(make_pair(q, q2));
    set<pair<int, int> >::iterator it3 = st2.upper_bound(make_pair(q, q2));
    st1.erase(it);
    int qq = q;
    int qqq = q2;
    if (it2 == st2.begin() || it3 == st2.end()) {
      st2.erase(make_pair(q, q2));
      continue;
    }
    it2--;
    q = it2->first;
    int q3 = it2->second;
    q2 = it3->first;
    int q4 = it3->second;
    st2.erase(make_pair(qq, qqq));
    if (a[q] == a[q2]) {
      st1.erase(make_pair(q3, q));
      st1.erase(make_pair(q4, q2));
      st1.insert(make_pair(q3 + q4, q));
      st2.erase(it2);
      st2.erase(it3);
      st2.insert(make_pair(q, q3 + q4));
    }
  }
  printf("%d", ans + 1);
}
