#include <bits/stdc++.h>
using namespace std;
struct info {
  int p, v, c;
};
class compare {
 public:
  bool operator()(pair<int, int> x, pair<int, int> y) {
    if (x.first == y.first)
      return x.second < y.second;
    else
      return x.first > y.first;
  }
};
set<pair<int, int> > sota;
set<pair<int, int>, compare> mota;
set<pair<int, int> >::iterator it;
int ar[200010];
int main() {
  ios::sync_with_stdio(false);
  int i, j, n, m, p, v, c = 0;
  cin >> n;
  for (int i = 0; i <= n - 1; i++) cin >> ar[i];
  for (int i = 0; i <= n - 1; i++) {
    if (i == 0) {
      p = i;
      v = ar[i];
      c = 1;
    } else if (v == ar[i])
      c++;
    else {
      sota.insert(make_pair(p, c));
      mota.insert(make_pair(c, p));
      p = i;
      v = ar[i];
      c = 1;
    }
  }
  sota.insert(make_pair(p, c));
  mota.insert(make_pair(c, p));
  pair<int, int> ob, ob2, ob1;
  int st = 0;
  while (!mota.empty()) {
    st++;
    ob1 = ob2 = make_pair(n, n);
    ob = *(mota.begin());
    p = ob.second;
    c = ob.first;
    v = ar[p];
    sota.erase(make_pair(p, c));
    mota.erase(make_pair(c, p));
    if (sota.empty()) break;
    it = sota.lower_bound(make_pair(p, 0));
    if (it != sota.end()) ob1 = *it;
    if (it != sota.begin()) {
      it--;
      ob2 = *it;
    }
    if (ar[ob1.first] == ar[ob2.first] && ob1.first != n && ob2.first != n) {
      p = min(ob1.first, ob2.first);
      c = ob1.second + ob2.second;
      mota.erase(make_pair(ob2.second, ob2.first));
      mota.erase(make_pair(ob1.second, ob1.first));
      sota.erase(ob1);
      sota.erase(ob2);
      sota.insert(make_pair(p, c));
      mota.insert(make_pair(c, p));
    }
  }
  cout << st << '\n';
  return 0;
}
