#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using pi = pair<int, int>;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const int mxa = 1e7;
const int mxn = 2e5;
int n, a[mxn];
void solve() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  set<pi> len, seg;
  for (int i = 0; i < n;) {
    int cnt = 0;
    while (i < n && a[i] == a[i - cnt]) {
      ++i, ++cnt;
    }
    len.insert({-cnt, i - cnt});
    seg.insert({i - cnt, cnt});
  }
  int ans = 0;
  while (!len.empty()) {
    pi p = *(len.begin());
    len.erase(p);
    ++ans;
    auto it = seg.lower_bound({p.second, -p.first}), itp = it, itn = it;
    itp == seg.begin() ? itp = seg.end() : --itp;
    ++itn;
    if (itp != seg.end() && itn != seg.end() &&
        a[itp->first] == a[itn->first]) {
      pi add = {itp->first, itp->second + itn->second}, pre = *itp, nex = *itn;
      len.insert({-add.second, add.first});
      len.erase({-pre.second, pre.first});
      len.erase({-nex.second, nex.first});
      seg.insert(add);
      seg.erase(pre);
      seg.erase(nex);
    }
    seg.erase({p.second, -p.first});
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  t = 1;
  while (t--) solve();
}
