#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int arr[N], len[N];
set<pair<int, int>, greater<pair<int, int> > > s;
set<int> start;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, i;
  cin >> n;
  for (i = 1; 1 < n + 1 ? i < n + 1 : i > n + 1; 1 < n + 1 ? i += 1 : i -= 1) {
    cin >> arr[i];
  }
  int st = 1;
  for (i = 2; 2 < n + 1 ? i < n + 1 : i > n + 1; 2 < n + 1 ? i += 1 : i -= 1) {
    if (arr[i] != arr[i - 1]) {
      start.insert(st);
      len[st] = i - st;
      s.insert(make_pair(len[st], -st));
      st = i;
    }
  }
  start.insert(st);
  len[st] = n - st + 1;
  s.insert(make_pair(len[st], -st));
  int ans = 0;
  while (!s.empty()) {
    auto it = s.begin();
    int pos = -(it->second);
    s.erase(s.begin());
    if (start.find(pos) == start.end()) {
      continue;
    }
    start.erase(pos);
    ans++;
    if (!start.empty()) {
      auto to = start.lower_bound(pos);
      if (to != start.begin() and to != start.end()) {
        int rt = *to;
        --to;
        int lt = *to;
        if (arr[lt] == arr[rt]) {
          len[lt] += len[rt];
          s.insert(make_pair(len[lt], -lt));
          start.erase(rt);
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
