#include <bits/stdc++.h>
using namespace std;
const int block_size = 320;
const long long mod = 1e9 + 7;
const long long inf = 1e9 + 7;
const long double eps = 1e-9;
const double PI = atan(1) * 4;
template <typename T>
inline int sign(const T &a) {
  if (a < 0) return -1;
  if (a > 0) return 1;
  return 0;
}
template <typename T>
inline void in(T &x) {
  x = 0;
  T f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
long long twop(int x) { return 1LL << x; }
template <typename A, typename B>
inline void in(A &x, B &y) {
  in(x);
  in(y);
}
template <typename A, typename B, typename C>
inline void in(A &x, B &y, C &z) {
  in(x);
  in(y);
  in(z);
}
template <typename A, typename B, typename C, typename D>
inline void in(A &x, B &y, C &z, D &d) {
  in(x);
  in(y);
  in(z);
  in(d);
}
template <class T>
void upd(T &a, T b) {
  a = max(a, b);
}
struct segment {
  int value, length, start;
  bool operator<(const segment &o) const {
    if (length != o.length) return length < o.length;
    return start > o.start;
  }
};
struct cmp {
  bool operator()(const segment &a, const segment &b) const {
    return a.start < b.start;
  }
};
priority_queue<segment> pq;
set<segment, cmp> s;
int main() {
  int n;
  in(n);
  int last = -1, len;
  for (long long i = 0; i < n; i++) {
    int v;
    in(v);
    if (last == -1) {
      last = v;
      len = 1;
    } else if (last == v)
      len++;
    else {
      segment foo;
      foo.length = len;
      foo.start = i;
      foo.value = last;
      s.insert(foo);
      pq.push(foo);
      last = v;
      len = 1;
    }
  }
  segment foo;
  foo.length = len;
  foo.start = n;
  foo.value = last;
  s.insert(foo);
  pq.push(foo);
  foo.start = -10000;
  foo.value = -1;
  foo.length = -1;
  s.insert(foo);
  pq.push(foo);
  foo.value = -2;
  foo.start = inf;
  foo.length = -1;
  s.insert(foo);
  pq.push(foo);
  int ans = 0;
  while (((int)s.size()) > 2) {
    ans++;
    while (s.count(pq.top()) == 0) pq.pop();
    auto curSeg = pq.top();
    pq.pop();
    s.erase(curSeg);
    auto p1 = s.lower_bound(curSeg);
    auto p2 = p1;
    --p2;
    if (p2->value == p1->value) {
      curSeg.value = p2->value;
      curSeg.length = p2->length + p1->length;
      curSeg.start = p2->start;
      s.erase(p1);
      s.erase(p2);
      s.insert(curSeg);
      pq.push(curSeg);
    }
  }
  cout << ans << endl;
  return 0;
}
