#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (T i : v) os << i << ' ';
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const set<T>& v) {
  for (T i : v) os << i << ' ';
  return os;
}
template <class T, class S>
ostream& operator<<(ostream& os, const pair<T, S>& v) {
  os << v.first << ' ' << v.second;
  return os;
}
template <class T, class S>
ostream& operator<<(ostream& os, const unordered_map<T, S>& v) {
  for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' ';
  return os;
}
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target( \
    "avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const long long N = 2e5 + 5;
const long long MAXN = 1e4 + 5;
const long long M = 3e5;
const long long mod = 1e9 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const long long LG = 21;
long long arr[N];
struct DSU {
  long long connected;
  long long par[N], sz[N];
  long long parr[N];
  DSU() {}
  DSU(long long n) {
    for (long long i = 1; i <= n; i++) {
      par[i] = i;
      parr[i] = i;
      sz[i] = 1;
    }
    connected = n;
  }
  long long getPar(long long k) {
    while (k != par[k]) {
      par[k] = par[par[k]];
      k = par[k];
    }
    return k;
  }
  long long getSize(long long k) { return sz[getPar(k)]; }
  void unite(long long u, long long v) {
    long long par1 = getPar(u), par2 = getPar(v);
    if (par1 == par2) return;
    connected--;
    if (sz[par1] > sz[par2]) swap(par1, par2);
    sz[par2] += sz[par1];
    sz[par1] = 0;
    par[par1] = par[par2];
    parr[par2] = min(parr[par1], parr[par2]);
    0;
  }
};
void solve() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  DSU D(n);
  set<long long> idx;
  set<long long> jdx;
  for (long long i = 1; i <= n; i++) {
    idx.insert(i);
    jdx.insert(-i);
  }
  for (long long i = 1; i <= n - 1; i++) {
    if (arr[i] == arr[i + 1]) {
      D.unite(i, i + 1);
    }
  }
  set<pair<long long, long long>> m;
  for (long long i = 1; i <= n;) {
    m.insert({-1 * D.getSize(i), i});
    i += D.getSize(i);
  }
  long long cnt = 0;
  while (m.size()) {
    cnt++;
    auto it = *m.begin();
    m.erase(m.begin());
    long long sz = -1 * it.first;
    long long j = it.second;
    auto to = idx.lower_bound(it.second);
    vector<long long> del;
    while (to != idx.end() and arr[*to] == arr[j]) {
      del.push_back(*to);
      to++;
    }
    for (long long x : del) {
      idx.erase(x);
      jdx.erase(-x);
    }
    long long s = 0;
    auto it1 = jdx.lower_bound(-j);
    auto it2 = idx.lower_bound(j);
    0;
    if (it1 != jdx.end() and it2 != idx.end()) {
      long long idx1 = *it1;
      long long idx2 = *it2;
      idx1 *= -1;
      if (arr[idx1] == arr[idx2]) {
        m.erase({-D.getSize(idx1), D.parr[D.getPar(idx1)]});
        m.erase({-D.getSize(idx2), D.parr[D.getPar(idx2)]});
        D.unite(idx1, idx2);
        0;
        0;
        m.insert({-1 * D.getSize(idx1), D.parr[D.getPar(idx1)]});
      }
    }
  }
  cout << cnt << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) solve();
  return 0;
}
