#include <bits/stdc++.h>
using namespace std;
template <typename X>
void MA(X& a, X b) {
  a = max(a, b);
}
template <typename X>
void MI(X& a, X b) {
  a = min(a, b);
}
template <typename X>
void clr(X& x, int a) {
  memset(x, a, sizeof(a));
};
int cond = 0, multi = 0, gcj = 0;
struct solver_t;
solver_t* solver;
struct solver_t {
  int N;
  struct interval_t;
  set<interval_t> all_int;
  map<int, interval_t> m2i;
  struct interval_t {
    int val = 0, cnt = 0, pos = 0;
    interval_t() {}
    interval_t(int val, int cnt, int pos) : val(val), cnt(cnt), pos(pos) {}
    bool operator<(const interval_t& rhs) const {
      if (cnt != rhs.cnt) return cnt > rhs.cnt;
      return pos < rhs.pos;
    }
    void unregister() {
      solver->all_int.erase(*this);
      solver->m2i.erase(pos);
    }
    void registerx() {
      solver->m2i[pos] = *this;
      solver->all_int.insert(*this);
    }
  };
  solver_t() {}
  void solve() {
    cin >> N;
    vector<int> A(N + 1);
    for (auto i = (0); i < (N); ++i) cin >> A[i];
    int last_val = A[0];
    int last_cnt = 1;
    for (auto i = (1); i <= (N); ++i) {
      if (i == N || A[i] != A[i - 1]) {
        interval_t(A[i - 1], last_cnt, i - 1).registerx();
        last_val = A[i];
        last_cnt = 1;
      } else
        last_cnt++;
      if (i == N) break;
    }
    int res = 0;
    while (!all_int.empty()) {
      res++;
      auto first_cur = all_int.begin();
      auto first_val = *first_cur;
      first_val.unregister();
      m2i.erase(first_val.pos);
      auto cur = m2i.lower_bound(first_val.pos);
      if (cur != m2i.begin() && cur != m2i.end()) {
        auto cur_prev = cur;
        cur_prev--;
        if (cur->second.val == cur_prev->second.val) {
          auto v1 = cur_prev->second;
          auto v2 = cur->second;
          v1.unregister();
          v2.unregister();
          interval_t(v1.val, v1.cnt + v2.cnt, v1.pos).registerx();
        }
      }
    }
    cout << res << "\n";
  }
};
int main(int argc, char** argv) {
  ios::sync_with_stdio(false), cin.tie(0),
      cond = argc >= 2 && argv[1][0] == 'q' ? 1 << 30 : 0;
  cout.setf(ios::fixed), cout.precision(10);
  int t;
  if (multi || gcj)
    cin >> t;
  else
    t = 1;
  for (auto i = (1); i <= (t); ++i) {
    if (cond) cerr << 102 << " " << i << endl;
    if (gcj) cout << "Case #" << i << ": ";
    solver = new solver_t();
    solver->solve();
  }
  return 0;
}
