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