#include <bits/stdc++.h>
using namespace std;
class range {
 public:
  int l, r, v, s;
  range(int i, int j, int k, int e) { l = i, r = j, v = k, s = e; }
  range() {}
  bool operator<(const range& g) const { return l < g.l; }
};
class range2 {
 public:
  int l, r, v, s;
  range2(int i, int j, int k, int e) { l = i, r = j, v = k, s = e; }
  range2() {}
  range2(range g) { l = g.l, r = g.r, v = g.v, s = g.s; }
  bool operator<(const range2& g) const {
    return (s < g.s) || g.s == s && l > g.l;
  }
};
int n, x[200200], l, p, ans;
multiset<range> r;
multiset<range2> r2;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", x + i);
  }
  for (int i = 1; i <= n; ++i) {
    l = i;
    while (x[i] == x[i + 1]) ++i;
    r.insert(range(l, i, x[i], i - l + 1));
    r2.insert(range2(l, i, x[i], i - l + 1));
  }
  while (r2.size()) {
    ans++;
    multiset<range2>::iterator itr2 = r2.end();
    --itr2;
    range rr2 = range(itr2->l, itr2->r, itr2->v, itr2->s);
    r.erase(rr2);
    r2.erase(rr2);
    multiset<range>::iterator itr = r.upper_bound(rr2);
    if (itr == r.end() || itr == r.begin()) continue;
    multiset<range>::iterator itl = itr;
    --itl;
    if (itl->v != itr->v) continue;
    range lr = *itl, rr = *itr;
    r.erase(lr);
    r.erase(rr);
    r2.erase(lr);
    r2.erase(rr);
    r.insert(range(lr.l, rr.r, rr.v, lr.s + rr.s));
    r2.insert(range(lr.l, rr.r, rr.v, lr.s + rr.s));
  }
  cout << ans;
}
