#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAX = 5e3 + 10;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  set<pair<int, int> > order;
  map<int, int> cnt;
  map<int, int> what;
  int prev = -1, c = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (prev != x) {
      if (prev != -1) {
        order.insert(pair<int, int>(-c, (i - 1)));
        cnt[i - 1] = c;
        what[i - 1] = prev;
      }
      c = 1;
    } else
      c++;
    prev = x;
  }
  order.insert(pair<int, int>(-c, n));
  cnt[n] = c;
  what[n] = prev;
  int ans = 0;
  while (order.size()) {
    pair<int, int> cur = *order.begin();
    cur.first *= -1;
    order.erase(order.begin());
    ans++;
    auto l = cnt.lower_bound(cur.second);
    auto r = cnt.lower_bound(cur.second);
    pair<int, int> nw = pair<int, int>(0, 0);
    if (l != cnt.begin()) {
      l--;
      if (++r != cnt.end()) {
        if (what[l->first] == what[r->first]) {
          order.erase(pair<int, int>(-l->second, l->first));
          order.erase(pair<int, int>(-r->second, r->first));
          r->second += l->second;
          order.insert(pair<int, int>(-r->second, r->first));
          cnt.erase(l);
        }
      }
    }
    cnt.erase(cur.second);
  }
  cout << ans << '\n';
}
