#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.1415926535897932384626433;
const long long inf = 1e18;
const long long mod = 1e9 + 7;
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<pair<long long, long long>> v;
  long long k = 1;
  for (long long i = 1; i < n; i++) {
    if (a[i] != a[i - 1]) {
      v.push_back({k, a[i - 1]});
      k = 1;
    } else {
      k++;
    }
  }
  v.push_back({k, a[n - 1]});
  set<pair<long long, long long>> s;
  long long par[n], chi[n];
  for (long long i = 0; i < v.size(); i++) {
    s.insert({v[i].first, -1 * i});
    par[i] = i - 1;
    chi[i] = i + 1;
  }
  long long ans = 0;
  while (s.size() != 0) {
    pair<long long, long long> p = *(--s.end());
    long long ind = p.second * -1;
    ans++;
    if (par[ind] != -1 and chi[ind] != n) {
      if (v[par[ind]].second == v[chi[ind]].second) {
        s.erase({v[ind].first, -ind});
        s.erase({v[chi[ind]].first, -chi[ind]});
        s.erase({v[par[ind]].first, -par[ind]});
        v[par[ind]].first += v[chi[ind]].first;
        v[chi[ind]].first = 0;
        s.insert({v[par[ind]].first, -par[ind]});
        chi[par[ind]] = chi[chi[ind]];
        par[chi[chi[ind]]] = par[ind];
      } else {
        s.erase({v[ind].first, -ind});
        chi[par[ind]] = chi[ind];
        par[chi[ind]] = par[ind];
      }
    } else {
      s.erase({v[ind].first, -ind});
      chi[par[ind]] = chi[ind];
      par[chi[ind]] = par[ind];
    }
    v[ind].first = 0;
  }
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
}
