#include <bits/stdc++.h>
using namespace std;
long long int MOD = 998244353;
long long int mod = 1e9 + 7;
long long int INF = 1e18 + 1;
long long int ma[200005];
long long int mb[200005];
long long int root(long long int x) {
  while (x != ma[x]) {
    ma[x] = ma[ma[x]];
    x = ma[x];
  }
  return x;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int d, i, w, j, k = 0, l = 0, r = 0, m = 0, n, c, p = 0, cnt = 0,
                            cnt1 = 0, x, y = 0, z = 0, a, b, low, mid, high,
                            ans = 0, maxi = 0, mini = INF, t1, x1, y1, t, o;
  string s, s1;
  long long qt, xx;
  char jj;
  cin >> n;
  long long int A[n];
  for (i = 0; i < n; i++) {
    cin >> A[i];
  }
  set<pair<long long int, long long int> > se;
  set<pair<long long int, long long int> > st2;
  set<pair<long long int, long long int> > st;
  set<pair<long long int, long long int> >::iterator it, bt;
  for (i = 0; i < n; i++) {
    j = i;
    cnt = 0;
    while (j < n && A[j] == A[i]) {
      j++;
      cnt++;
    }
    se.insert({-cnt, i});
    st.insert({i, -cnt});
    i = j - 1;
  }
  cnt = 0;
  while (!se.empty()) {
    cnt++;
    auto kk = *se.begin();
    a = kk.first;
    b = kk.second;
    if (se.size() == 1) break;
    it = st.lower_bound({b, a});
    bt = st.upper_bound({b, a});
    if (it == st.begin()) {
      se.erase({a, b});
      st.erase({b, a});
      continue;
    } else
      it--;
    if (bt == st.end()) {
      se.erase({a, b});
      st.erase({b, a});
      continue;
    }
    se.erase({a, b});
    st.erase({b, a});
    if (A[(*(it)).first] == A[((*(bt)).first)]) {
      a = (*(it)).second + (*(bt)).second;
      se.erase({(*(it)).second, (*(it)).first});
      se.erase({(*(bt)).second, ((*(bt)).first)});
      st.erase({(*it).first, (*it).second});
      st.erase({((*bt).first), (*bt).second});
      se.insert({a, ((*(it)).first)});
      st.insert({((*(it)).first), a});
    }
  }
  cout << cnt << endl;
}
