#include <bits/stdc++.h>
using namespace std;
const long long INF = 10e18;
const long long maxn = 2e5;
long long n, prev_x = 0, ans = 0, a[maxn];
set<pair<long long, long long> > st1, st2;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 1; i < n; ++i) {
    if (a[i] != a[i - 1]) {
      st1.insert({-(i - prev_x), prev_x});
      st2.insert({prev_x, i - prev_x});
      prev_x = i;
    }
  }
  st1.insert({-(n - prev_x), prev_x});
  st2.insert({prev_x, n - prev_x});
  while (!st1.empty()) {
    ans++;
    pair<long long, long long> cur = *st1.begin();
    st1.erase(st1.begin());
    auto it = st2.find({cur.second, abs(cur.first)}), tmp = st2.end();
    tmp--;
    if (it != st2.begin() && it != tmp) {
      it++;
      auto tmp2 = it;
      it--, it--;
      auto tmp1 = it;
      it++;
      long long start = (*tmp1).first, len = (*tmp1).second + (*tmp2).second;
      long long test = (*tmp1).first, test1 = (*tmp2).first, test2 = len;
      if (a[(*tmp1).first] == a[(*tmp2).first]) {
        st1.insert({-len, start});
        st2.insert({start, len});
        st2.erase(tmp2);
        st2.erase(it);
        st2.erase(tmp1);
        auto kek1 = st1.find({-((*tmp1).second), (*tmp1).first});
        auto kek2 = st1.find({-((*tmp2).second), (*tmp2).first});
        st1.erase(kek2);
        st1.erase(kek1);
      } else {
        st2.erase(it);
      }
    } else {
      st2.erase(it);
    }
  }
  cout << ans;
  return 0;
}
