#include <bits/stdc++.h>
using namespace std;
set<pair<long long, long long> > s1;
set<long long> s2;
long long a[212345], d[212345];
signed main() {
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  long long l = 1, cnt = 0;
  for (long long i = 1; i <= n + 1; i++) {
    if (a[i] == a[l])
      cnt++;
    else {
      s1.insert(make_pair(-1 * cnt, l));
      s2.insert(l);
      d[l] = cnt;
      cnt = 1;
      l = i;
    }
  }
  long long ans = 0;
  while (!s1.empty()) {
    pair<long long, long long> now = *s1.begin();
    s1.erase(s1.begin());
    ans++;
    l = now.second;
    set<long long>::iterator it = s2.find(l), it1 = it, it2 = it;
    it2++;
    if (it1 == s2.begin() || it2 == s2.end()) {
      s2.erase(it);
      continue;
    }
    it1--;
    if (a[*it1] != a[*it2]) {
      s2.erase(it);
      continue;
    }
    long long l1 = *it1, l2 = *it2;
    s1.erase(make_pair(-1 * d[l1], l1));
    s1.erase(make_pair(-1 * d[l2], l2));
    d[l1] += d[l2];
    s1.insert(make_pair(-1 * (d[l1]), l1));
    s2.erase(it);
    s2.erase(l2);
  }
  cout << ans << '\n';
  return 0;
}
