#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 2;
const int INF = 1e9 + 7;
struct node1 {
  int len;
};
struct node2 {
  int id;
  node1 info;
};
struct orden {
  bool operator()(const node2 &l1, const node2 &l2) {
    if (l1.info.len != l2.info.len) return l1.info.len > l2.info.len;
    return l1.id < l2.id;
  }
};
int num[N];
set<node2, orden> s;
set<int> ids;
node1 info[N];
int getPrev(set<int>::iterator it) {
  if (it == ids.begin()) return -1;
  it--;
  return *it;
}
int getNext(set<int>::iterator it) {
  it++;
  if (it == ids.end()) return -1;
  return *it;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &num[i]);
  }
  int len = 1;
  for (int i = 2; i <= n + 1; i++) {
    if (num[i - 1] != num[i]) {
      ids.insert(i - 1);
      info[i - 1] = {len};
      s.insert({i - 1, info[i - 1]});
      len = 0;
    }
    len++;
  }
  int ans = 0;
  for (; !s.empty(); ans++) {
    auto it = ids.lower_bound(s.begin()->id);
    s.erase(s.begin());
    int prev = getPrev(it);
    int next = getNext(it);
    ids.erase(it);
    if (prev == -1 || next == -1) continue;
    if (num[prev] == num[next]) {
      s.erase({prev, info[prev]});
      s.erase({next, info[next]});
      ids.erase(next);
      info[prev].len += info[next].len;
      s.insert({prev, info[prev]});
    }
  }
  cout << ans;
  return 0;
}
