#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5;
const long long mod = 998244353;
inline long long read() {
  long long s = 0;
  register bool neg = 0;
  register char c = getchar();
  for (; c < '0' || c > '9'; c = getchar()) neg |= (c == '-');
  for (; c >= '0' && c <= '9'; s = s * 10 + (c ^ 48), c = getchar())
    ;
  s = (neg ? -s : s);
  return s;
}
long long a, q[N + 10], l[N + 10], r[N + 10];
bool vis[N + 10];
struct node {
  long long l, r, len;
  bool operator<(const node &o) const {
    return len < o.len || (len == o.len && l > o.l);
  }
};
priority_queue<node> qu;
signed main() {
  a = read();
  for (long long i = 1; i <= a; i++) q[i] = read(), l[i] = i - 1, r[i] = i + 1;
  for (long long i = 1; i <= a;) {
    long long j = i;
    while (j <= a && q[j + 1] == q[i]) j++;
    qu.push((node){i, j, j - i + 1});
    i = j + 1;
  }
  long long ans = 0;
  while (!qu.empty()) {
    node p = qu.top();
    qu.pop();
    if (vis[p.l]) continue;
    ans++;
    for (long long i = p.l; i <= p.r; i++) vis[i] = 1;
    r[l[p.l]] = r[p.r];
    l[r[p.r]] = l[p.l];
    if (q[l[p.l]] == q[r[p.r]] && l[p.l] >= 1 && r[p.r] <= a) {
      node res;
      res.len = 0;
      res.l = p.l;
      res.r = p.r;
      long long tmp = q[l[res.l]];
      while (q[l[res.l]] == tmp) res.l = l[res.l], res.len++;
      while (q[r[res.r]] == tmp) res.r = r[res.r], res.len++;
      qu.push(res);
    }
  }
  printf("%lld", ans);
  return 0;
}
