#include <bits/stdc++.h>
using namespace std;
long long spf[301];
long long fac[301];
void sieve() {
  spf[1] = 1;
  for (long long i = 2; i < 301; i++) spf[i] = i;
  for (long long i = 4; i < 301; i += 2) spf[i] = 2;
  for (long long i = 3; i * i < 301; i++) {
    if (spf[i] == i) {
      for (long long j = i * i; j < 301; j += i)
        if (spf[j] == j) spf[j] = i;
    }
  }
}
map<long long, long long> getfactor(long long a) {
  map<long long, long long> m;
  while (a > 1) {
    m[spf[a]]++;
    a /= spf[a];
  }
  return m;
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long inverse(long long a, long long p) { return power(a, p - 2, p); }
long long ncr(long long n, long long r, long long p) {
  if (r > n) return 0;
  if (r == 0) return 1;
  return (fac[n] * inverse(fac[r], p) % p * inverse(fac[n - r], p) % p) % p;
}
void solve() {
  long long n;
  cin >> n;
  long long a[n + 1];
  for (long long i = 1; i <= n; i++) cin >> a[i];
  long long l = 1, cur = a[1];
  multiset<pair<pair<long long, long long>, long long> > s1, s2;
  map<long long, long long> m;
  for (long long i = 1; i <= n; i++) {
    if (a[i] != cur) {
      m[i - 1] = cur;
      m[l] = cur;
      s1.insert(make_pair(make_pair(i - l, -l), -(i - 1)));
      s2.insert(make_pair(make_pair(l, i - 1), i - l));
      l = i;
    }
    cur = a[i];
  }
  s1.insert(make_pair(make_pair(n + 1 - l, -l), -n));
  s2.insert(make_pair(make_pair(l, n), n + 1 - l));
  m[n] = cur;
  m[l] = cur;
  long long ans = 0;
  while (s1.size() > 0) {
    ans++;
    auto it = s1.end();
    it--;
    auto it2 = s2.lower_bound(
        (make_pair(make_pair(-it->first.second, -it->second), 0ll)));
    if (it2 == s2.begin()) {
      s1.erase(it);
      s2.erase(it2);
    } else if (*it2 == *s2.rbegin()) {
      s1.erase(it);
      s2.erase(it2);
    } else {
      auto it3 = it2;
      auto it4 = it2;
      it3--;
      it4++;
      s1.erase(it);
      s2.erase(it2);
      if (m[it3->first.first] == m[it4->first.first]) {
        long long len1 = it3->second;
        long long len2 = it4->second;
        s1.erase(
            make_pair(make_pair(len1, -it3->first.first), -it3->first.second));
        s1.erase(
            make_pair(make_pair(len2, -it4->first.first), -it4->first.second));
        s1.insert(make_pair(make_pair(len1 + len2, -it3->first.first),
                            -it4->first.second));
        s2.insert(make_pair(make_pair(it3->first.first, it4->first.second),
                            len1 + len2));
        s2.erase(it3);
        s2.erase(it4);
      }
    }
  }
  cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long test = 1;
  while (test--) {
    solve();
  }
}
