#include <bits/stdc++.h>
using namespace std;
int n, a[200005], l[200005], r[200005], vis[200005];
vector<pair<int, int> > v;
void solve() {
  cin >> n;
  for (int i = 1; i < n + 1; i++) cin >> a[i];
  for (int i = 1; i < n + 1; i++) {
    if (!v.empty() and v.back().second == a[i])
      v.back().first++;
    else
      v.push_back({1, a[i]});
  }
  priority_queue<pair<int, int> > pq;
  for (int i = 0; i < (int)v.size(); i++) {
    pq.push({v[i].first, -i});
    if (i)
      l[i] = i - 1;
    else
      l[i] = -1;
    if (i + 1 < (int)v.size())
      r[i] = i + 1;
    else
      r[i] = -1;
  }
  int ans = 0;
  while (!pq.empty()) {
    auto d = pq.top();
    pq.pop();
    int i = -d.second;
    if (vis[i]) continue;
    vis[i] = 1;
    ans++;
    if (l[i] != -1 and r[i] != -1) {
      if (v[l[i]].second == v[r[i]].second) {
        v[l[i]].first += v[r[i]].first;
        v[r[i]].first = 0;
        vis[r[i]] = 1;
        pq.push({v[l[i]].first, -l[i]});
        r[l[i]] = r[r[i]];
        if (r[r[i]] != -1) l[r[r[i]]] = l[i];
      } else {
        l[r[i]] = l[i];
        r[l[i]] = r[i];
      }
    } else if (l[i] != -1)
      r[l[i]] = -1;
    else if (r[i] != -1)
      l[r[i]] = -1;
  }
  cout << ans << '\n';
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
