#include <bits/stdc++.h>
struct segment {
  segment(uint32_t start, uint32_t len) : start(start), len(len) {}
  uint32_t start;
  uint32_t len;
};
struct comp_length {
  inline bool operator()(const segment* const lhs,
                         const segment* const rhs) const {
    if (lhs->len > rhs->len) {
      return true;
    } else if (lhs->len < rhs->len) {
      return false;
    } else {
      return lhs->start < rhs->start;
    }
  }
};
template <typename T, typename ComparatorT>
struct reverse_comparator {
  inline bool operator()(const T& lhs, const T& rhs) const {
    return !ComparatorT()(lhs, rhs);
  }
};
struct comp_start {
  inline bool operator()(const segment* const lhs,
                         const segment* const rhs) const {
    return lhs->start < rhs->start;
  }
};
int main() {
  size_t n = 0;
  std::cin >> n;
  std::vector<uint32_t> data_raw(n, 0);
  std::vector<segment> data_segs;
  for (size_t i = 0; i < n; i++) {
    std::cin >> data_raw[i];
    if (!i || data_raw[i] != data_raw[i - 1]) {
      data_segs.emplace_back(i, 1);
    } else {
      data_segs[data_segs.size() - 1].len += 1;
    }
  }
  std::set<segment*, comp_length> slen;
  std::set<segment*, comp_start> spos;
  for (auto& seg : data_segs) {
    slen.emplace(&seg);
    spos.emplace(&seg);
  }
  size_t ret = 0;
  while (slen.size()) {
    auto ittoplen = slen.begin();
    auto itpos = spos.find(*ittoplen);
    auto before = itpos == spos.begin() ? spos.end() : std::prev(itpos);
    auto after = std::next(itpos);
    if (before != spos.end() && after != spos.end()) {
      auto pbefore = *before, pafter = *after;
      if (data_raw[pbefore->start] == data_raw[pafter->start]) {
        slen.erase(pbefore);
        slen.erase(pafter);
        spos.erase(after);
        pbefore->len += pafter->len;
        slen.emplace(pbefore);
      }
    }
    slen.erase(ittoplen);
    spos.erase(itpos);
    ret += 1;
  }
  std::cout << ret << '\n';
  return 0;
}
