#include <bits/stdc++.h>
using namespace std;
int main() {
  iostream::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = (0); i < (n); ++i) {
    cin >> a[i];
  }
  map<long long, long long> m, cc;
  m[0] = a[0];
  long long cnt = 1;
  for (long long i = (1); i < (n); ++i) {
    if (a[i - 1] != a[i]) {
      cc[i - cnt] = cnt;
      cnt = 0;
      m[i] = a[i];
    }
    cnt++;
  }
  cc[n - cnt] = cnt;
  multiset<pair<long long, long long> > st1, st2;
  map<long long, long long>::iterator it = m.begin();
  while (it != m.end()) {
    st1.insert(make_pair(-1 * cc[it->first], it->first));
    st2.insert(make_pair(it->first, cc[it->first]));
    it++;
  }
  long long ans = 0;
  while (!st1.empty()) {
    pair<long long, long long> itm = *st1.begin();
    pair<long long, long long> item = make_pair(itm.second, -1 * itm.first);
    st1.erase(st1.begin());
    multiset<pair<long long, long long> >::iterator it1, it2, it3;
    it1 = st2.find(item);
    it2 = it1;
    it3 = it1;
    it2--;
    it3++;
    st2.erase(it1);
    if (it3 != st2.begin() && it3 != st2.end() &&
        m[it3->first] == m[it2->first]) {
      pair<long long, long long> aaa = *it2;
      st1.erase(make_pair(-1 * it2->second, it2->first));
      st1.erase(make_pair(-1 * it3->second, it3->first));
      aaa.second += it3->second;
      st2.erase(it2);
      st2.erase(it3);
      st2.insert(aaa);
      st1.insert(make_pair(-1 * aaa.second, aaa.first));
    }
    ans++;
  }
  cout << ans;
}
