#include <bits/stdc++.h>
using namespace std;
struct segment {
  int Ind, Len;
  bool operator<(const segment &other) const {
    if (Len != other.Len) return Len < other.Len;
    return Ind > other.Ind;
  }
};
const int N = 2e5 + 5;
int n;
int arr[N];
bool done[N];
priority_queue<segment> pq;
set<pair<int, pair<int, int> > > s;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", arr + i);
  for (int i = 0; i < n;) {
    int cur = arr[i], cnt = 0;
    while (i < n && arr[i] == cur) cnt++, i++;
    pq.push({i - 1, cnt});
    s.insert({i - 1, {cnt, cur}});
  }
  int steps = 0;
  while (pq.size()) {
    auto cur = pq.top();
    pq.pop();
    if (done[cur.Ind]) continue;
    steps++;
    auto seg = *s.lower_bound({cur.Ind, {-1, -1}});
    if (seg == *s.begin() || seg == *s.rbegin()) {
      s.erase(seg);
      continue;
    }
    s.erase(seg);
    auto it = s.upper_bound(seg);
    auto fir = *it;
    auto sec = *--it;
    if (fir.second.second == sec.second.second) {
      done[fir.first] = done[sec.first] = 1;
      auto nw = make_pair(
          cur.Ind,
          make_pair(fir.second.first + sec.second.first, fir.second.second));
      s.erase(fir), s.erase(sec);
      pq.push({cur.Ind, fir.second.first + sec.second.first});
      s.insert(nw);
    }
  }
  printf("%d", steps);
}
