#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &A) {
  for (long long i = 0; i < A.size(); i++) os << A[i] << " ";
  os << endl;
  return os;
}
template <>
ostream &operator<<(ostream &os, const vector<vector<long long> > &A) {
  long long N = A.size();
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < A[i].size(); j++) os << A[i][j] << " ";
    os << endl;
  }
  return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &A) {
  for (long long i = 0; i < (long long)(A.size()); i++) is >> A[i];
  return is;
}
struct edge {
  long long from, to, d, c, i;
  edge(long long _from = 0, long long _to = 0, long long _d = 0,
       long long _c = 0) {
    from = _from;
    to = _to;
    d = _d;
    c = _c;
  }
  bool operator<(const edge &rhs) const {
    return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
  }
};
struct aabb {
  long long x1, y1, x2, y2;
  aabb(long long x1, long long y1, long long x2, long long y2)
      : x1(x1), y1(y1), x2(x2), y2(y2) {}
};
struct flow {
  long long to, cap, rev, cost;
  flow(long long to = 0, long long cap = 0, long long rev = 0,
       long long cost = 0)
      : to(to), cap(cap), rev(rev), cost(cost) {}
};
const long long di[4] = {0, -1, 0, 1};
const long long dj[4] = {-1, 0, 1, 0};
const long long ci[5] = {0, 0, -1, 0, 1};
const long long cj[5] = {0, -1, 0, 1, 0};
const long long LINF = LLONG_MAX / 2;
const long long INF = INT_MAX / 2;
const long double PI = acos(-1);
long long pow2(long long n) { return 1LL << n; }
template <typename T, typename U>
bool chmin(T &x, const U &y) {
  if (x > y) {
    x = y;
    return true;
  }
  return false;
}
template <typename T, typename U>
bool chmax(T &x, const U &y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  fill((T *)array, (T *)(array + N), val);
}
struct initializer {
  initializer() { cout << fixed << setprecision(20); }
};
initializer _____;
struct seg {
  long long l, val, d;
  seg(long long l, long long val, long long d) : l(l), val(val), d(d) {}
};
bool operator<(const seg &lhs, const seg &rhs) {
  if (lhs.l == rhs.l) return lhs.d < rhs.d;
  return lhs.l < rhs.l;
}
long long N, M, K, T, Q, H, W;
signed main() {
  cin >> N;
  vector<long long> A(N);
  for (long long i = 0; i < (long long)(N); i++) cin >> A[i];
  long long l = 0;
  set<seg> s;
  for (long long i = 0; i < (long long)(N); i++) {
    if (i == N - 1 || A[i] != A[i + 1]) {
      s.emplace(l, A[i], i - l + 1);
      l = i + 1;
    }
  }
  priority_queue<pair<long long, long long> > q;
  for (auto &sg : s) {
    q.push(pair<long long, long long>(sg.d, -sg.l));
  }
  long long ans = 0;
  while (!q.empty()) {
    long long d, l;
    long long f = 0;
    while (1) {
      if (q.empty()) {
        f = 1;
        break;
      }
      tie(d, l) = q.top();
      l = -l;
      q.pop();
      auto it = s.lower_bound(seg(l, 0, -100));
      if (it->l == l && it->d == d) break;
    }
    if (f) break;
    auto it = s.lower_bound(seg(l, 0, -100));
    ans++;
    if (it != s.begin()) {
      auto it2 = it;
      it2--;
      it++;
      if (it != s.end() && it->val == it2->val) {
        seg ns(it2->l, it2->val, it2->d + it->d);
        s.erase(it2);
        s.erase(it);
        s.insert(ns);
        q.emplace(ns.d, -ns.l);
      }
    }
    it = s.lower_bound(seg(l, 0, -100));
    s.erase(it);
  }
  cout << ans << endl;
  return 0;
}
