#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int a[N];
bool del[N];
int L[N], R[N], len[N];
int pre[N], nxt[N];
struct P {
  int l, r, len;
  bool operator<(const P &A) const {
    if (len != A.len) return len < A.len;
    return l > A.l;
  }
};
int main() {
  int n;
  cin >> n;
  set<P> s;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    pre[i] = i - 1;
    nxt[i] = i + 1;
  }
  for (int i = 1, j = 1; i <= n; i = j) {
    while (j <= n && a[j] == a[i]) j++;
    s.insert(P{i, j - 1, j - i});
    L[j - 1] = i;
    R[i] = j - 1;
    len[i] = j - i;
  }
  int ans = 0;
  del[0] = del[n + 1] = 1;
  while (!s.empty()) {
    auto p = *s.rbegin();
    s.erase(p);
    ans++;
    del[p.l] = del[p.r] = 1;
    if (!del[pre[p.l]] && !del[nxt[p.r]] && a[pre[p.l]] == a[nxt[p.r]]) {
      int l = L[pre[p.l]], r = R[nxt[p.r]];
      s.erase(P{l, R[l], len[l]});
      s.erase(P{L[r], r, len[L[r]]});
      len[l] += len[L[r]];
      L[r] = l;
      R[l] = r;
      s.insert(P{l, r, len[l]});
    } else {
      int l = pre[p.l], r = nxt[p.r];
      nxt[l] = r;
      pre[r] = l;
    }
  }
  cout << ans << '\n';
  return 0;
}
