#include <bits/stdc++.h>
using namespace std;
long long int a[200005], a1[200005];
int main() {
  long long int n, i, j;
  while (cin >> n) {
    for (i = 1; i < n + 1; i++) cin >> a[i];
    set<pair<long long int, long long int> > s;
    set<long long int> s1;
    for (i = 1; i <= n; i++) {
      long long int cn = 0;
      for (j = i; j <= n; j++) {
        if (a[i] == a[j])
          cn++;
        else
          break;
      }
      s.insert(make_pair(-cn, i));
      a1[i] = cn;
      s1.insert(i);
      i = i + cn - 1;
    }
    a[0] = 0;
    a[n + 1] = 2000000000;
    s1.insert(0);
    s1.insert(n + 1);
    long long int ans = 0;
    long long int tot = 0;
    while (1) {
      pair<long long int, long long int> p = *s.begin();
      tot += (-p.first);
      long long int ind = p.second;
      s1.erase(s1.find(ind));
      long long int left = *--s1.lower_bound(ind);
      long long int right = *s1.upper_bound(ind);
      s.erase(s.find(p));
      if (a[left] == a[right]) {
        s1.erase(s1.find(right));
        pair<long long int, long long int> p1 = make_pair(-a1[left], left);
        pair<long long int, long long int> p2 = make_pair(-a1[right], right);
        s.erase(s.find(p1));
        s.erase(s.find(p2));
        a1[left] += a1[right];
        s.insert(make_pair(-a1[left], left));
      }
      ans++;
      if (tot == n) break;
    }
    cout << ans << endl;
  }
  return 0;
}
