#include <bits/stdc++.h>
using namespace std;
struct segment {
  int pos;
  int len;
  int type;
};
struct segmentByLength {
  segment seg;
  bool operator<(segmentByLength o) const {
    segment seg2 = o.seg;
    if (seg.len != seg2.len)
      return seg.len > seg2.len;
    else {
      return seg.pos < seg2.pos;
    }
  }
};
struct segmentByPosition {
  segment seg;
  bool operator<(segmentByPosition o) const {
    segment seg2 = o.seg;
    return seg.pos < seg2.pos;
  }
};
set<segmentByLength> lengthSet;
set<segmentByPosition> positionSet;
void add_segment(segment s) {
  lengthSet.insert({s});
  positionSet.insert({s});
}
void remove_segment(segment s) {
  lengthSet.erase({s});
  positionSet.erase({s});
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  a.push_back(1000000001);
  int start = 0;
  for (int i = 0; i < a.size(); i++) {
    if (i > 0 and a[i] != a[i - 1]) {
      segment s = {start, (i - 1) - start + 1, a[i - 1]};
      lengthSet.insert({{s}});
      positionSet.insert({{s}});
      start = i;
    }
  }
  int sol = 0;
  while (!lengthSet.empty()) {
    segment s = (*lengthSet.begin()).seg;
    segment left, right;
    bool leftExists = true, rightExists = true;
    auto lbIterator = positionSet.lower_bound({s});
    if (lbIterator != positionSet.begin()) {
      --lbIterator;
      left = (*lbIterator).seg;
    } else {
      leftExists = false;
    }
    auto ubIterator = positionSet.upper_bound({s});
    if (ubIterator != positionSet.end()) {
      right = (*ubIterator).seg;
    } else {
      rightExists = false;
    }
    remove_segment(s);
    if (leftExists and rightExists and left.type == right.type) {
      segment merged = {left.pos, left.len + right.len, left.type};
      remove_segment(left);
      remove_segment(right);
      add_segment(merged);
    }
    sol++;
  }
  cout << sol << '\n';
  return 0;
}
