#include <bits/stdc++.h>
using namespace std;
struct Triple {
  int64_t value, count, pos;
  Triple(int64_t value, int64_t count, int64_t pos)
      : value(value), count(count), pos(pos) {}
};
struct Pair {
  int64_t value, count;
  Pair(int64_t value = 0, int64_t count = 0) : value(value), count(count) {}
};
bool operator<(const Pair& left, const Pair& right) {
  return left.count < right.count ||
         (left.count == right.count && left.value < right.value);
}
bool operator<(const Triple& left, const Triple& right) {
  return left.count > right.count ||
         (left.count == right.count && left.pos < right.pos);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int64_t n;
  cin >> n;
  vector<int64_t> arr(n);
  for (auto& it : arr) {
    cin >> it;
  }
  vector<Triple> triples;
  triples.push_back(Triple(arr[0], 0, 0));
  for (int64_t i = 0; i < n; ++i) {
    if (arr[i] == triples.back().value) {
      triples.back().count++;
    } else {
      triples.push_back(Triple(arr[i], 1, i));
    }
  }
  map<int64_t, Pair> Map;
  for (auto& it : triples) {
    Map[it.pos] = Pair(it.value, it.count);
  }
  set<Triple> Set;
  for (auto& it : triples) {
    Set.insert(it);
  }
  int64_t answer = 0;
  while (!Set.empty()) {
    answer++;
    auto currSet = Set.begin();
    auto currMap = Map.find(currSet->pos);
    auto prevMap = std::prev(currMap);
    auto nextMap = std::next(currMap);
    if (currMap != Map.begin() && nextMap != Map.end()) {
      Pair prevElem = prevMap->second;
      Pair nextElem = nextMap->second;
      if (prevElem.value == nextElem.value) {
        Set.erase(Triple(prevElem.value, prevElem.count, prevMap->first));
        Set.erase(Triple(nextElem.value, nextElem.count, nextMap->first));
        prevElem.count += nextElem.count;
        prevMap->second = prevElem;
        Map.erase(nextMap);
        Set.insert(Triple(prevElem.value, prevElem.count, prevMap->first));
      }
    }
    Map.erase(currMap);
    Set.erase(currSet);
  }
  cout << answer;
  return 0;
}
