#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7, INF = 0x3f3f3f3f;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qpow(long long a, long long n) {
  long long r = 1 % P;
  for (a %= P; n; a = a * a % P, n >>= 1)
    if (n & 1) r = r * a % P;
  return r;
}
long long inv(long long first) {
  return first <= 1 ? 1 : inv(P % first) * (P - P / first) % P;
}
inline int rd() {
  int first = 0;
  char p = getchar();
  while (p < '0' || p > '9') p = getchar();
  while (p >= '0' && p <= '9') first = first * 10 + p - '0', p = getchar();
  return first;
}
const int N = 1e6 + 50;
int n, a[N], L[N], R[N], nxt[N], len[N];
struct _ {
  int l, r, c;
  bool operator<(const _ &rhs) const {
    if (c != rhs.c) return c > rhs.c;
    return l < rhs.l;
  }
};
set<_> s;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  for (int i = 1; i <= n; ++i) {
    int j = i;
    while (j < n && a[j + 1] == a[i]) ++j;
    s.insert({i, j, j - i + 1});
    L[i] = L[j] = i - 1, R[i] = R[j] = j + 1;
    nxt[i] = j, nxt[j] = i;
    len[i] = len[j] = j - i + 1;
    i = j;
  }
  int ans = 0;
  while (s.size()) {
    _ u = *s.begin();
    s.erase(s.begin());
    ++ans;
    if (L[u.l] && R[u.r] <= n && a[L[u.l]] == a[R[u.r]]) {
      int r1 = L[u.l], l1 = nxt[r1];
      int l2 = R[u.r], r2 = nxt[l2];
      s.erase({l1, r1, len[l1]});
      s.erase({l2, r2, len[l2]});
      L[r2] = L[l1];
      R[l1] = R[r2];
      nxt[l1] = r2, nxt[r2] = l1;
      len[l1] = len[r2] = len[l1] + len[r2];
      s.insert({l1, r2, len[l1]});
    } else {
      R[L[u.l]] = R[u.r];
      L[R[u.r]] = L[u.l];
    }
  }
  printf("%d\n", ans);
}
