#include <bits/stdc++.h>
using namespace std;
inline long long input() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
inline long long in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
const long long maxn = 2e5 + 10;
set<pair<long long, pair<long long, long long> > > st;
map<pair<long long, long long>, long long> mp;
set<pair<long long, long long> > copies;
long long a[maxn], b[maxn], where[maxn];
int32_t main() {
  long long n = in();
  for (long long i = 0; i < n; i++) a[i] = in();
  for (long long i = 0, j = 0; i < n; i++) {
    while (j + 1 < n && a[j + 1] == a[i]) j++;
    copies.insert({i, j});
    st.insert({-(j - i + 1), {i, j}});
    mp[{i, j}] = j - i + 1;
    i = j;
  }
  long long res = 0;
  while (st.size()) {
    res++;
    set<pair<long long, long long> >::iterator it =
        copies.lower_bound(st.begin()->second);
    pair<long long, long long> sss = *it;
    st.erase(st.begin());
    if (it != copies.begin() && it != copies.end()) {
      it--;
      pair<long long, long long> A = *it;
      it++;
      it++;
      if (it != copies.end() && a[A.first] == a[it->first]) {
        pair<long long, long long> B = *it;
        long long totSz = mp[{A.first, A.second}] + mp[{B.first, B.second}];
        mp[{A.first, B.second}] = totSz;
        st.erase({-mp[{A.first, A.second}], {A.first, A.second}});
        st.erase({-mp[{B.first, B.second}], {B.first, B.second}});
        st.insert({-totSz, {A.first, B.second}});
        copies.erase(A);
        copies.erase(B);
        copies.insert({A.first, B.second});
      }
    }
    copies.erase(sss);
  }
  cout << res << endl;
}
