#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5, inf = 1e9 + 7;
long long n, k, i, j;
long long A[N], l[N], r[N], len[N];
set<pair<long long, long long> > st;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long i, j, a, b, ans = 0, cur;
  cin >> n;
  for (i = 1; i < n + 1; i++) cin >> A[i];
  i = 1;
  while (i <= n) {
    j = i;
    while (j <= n && A[j] == A[i]) j++;
    r[i] = j;
    l[j] = i;
    len[i] = j - i;
    st.insert(pair<long long, long long>(i - j, i));
    i = j;
  }
  while (!st.empty()) {
    cur = st.begin()->second;
    st.erase(st.begin());
    ans++;
    len[cur] = 0;
    a = l[cur];
    b = r[cur];
    if (st.empty()) break;
    if (A[a] == A[b] && a > 0 && b <= n) {
      st.erase(pair<long long, long long>(-len[a], a));
      st.erase(pair<long long, long long>(-len[b], b));
      r[a] = r[b];
      l[r[a]] = a;
      len[a] += len[b];
      len[b] = 0;
      st.insert(pair<long long, long long>(-len[a], a));
    } else {
      r[a] = b;
      l[b] = a;
    }
  }
  cout << ans;
}
