#include <bits/stdc++.h>
using namespace std;
using pii = pair<pair<int, int>, int>;
using lit = list<pii>::iterator;
struct cmp {
  bool operator()(lit a, lit b) const {
    pii a1 = *a, b1 = *b;
    if (a1.second != b1.second)
      return a1.second > b1.second;
    else
      return a1.first.second < b1.first.second;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  a.emplace_back(0);
  list<pii> l;
  set<lit, cmp> s;
  int cnt = 1;
  for (int i = 0; i < n; i++) {
    if (a[i + 1] != a[i]) {
      l.push_back(make_pair(make_pair(a[i], i), cnt));
      cnt = 1;
      s.insert(prev(l.end()));
    } else
      cnt++;
  }
  int ans = 0;
  while (!s.empty()) {
    lit p = *s.begin();
    lit p1 = prev(p), p2 = next(p);
    ans++;
    s.erase(p);
    if (p == l.begin() || p2 == l.end()) {
      l.erase(p);
      continue;
    }
    if ((*p1).first.first != (*p2).first.first) {
      l.erase(p);
      continue;
    }
    s.erase(p1);
    s.erase(p2);
    (*p1).second += (*p2).second;
    s.insert(p1);
    l.erase(p2);
    l.erase(p);
  }
  cout << ans << endl;
}
