#include <bits/stdc++.h>
template <typename T>
inline void read(T &x) {
  char c;
  bool nega = 0;
  while ((!isdigit(c = getchar())) && (c != '-'))
    ;
  if (c == '-') {
    nega = 1;
    c = getchar();
  }
  x = c - 48;
  while (isdigit(c = getchar())) x = x * 10 + c - 48;
  if (nega) x = -x;
}
template <typename T>
inline void writep(T x) {
  if (x > 9) writep(x / 10);
  putchar(x % 10 + 48);
}
template <typename T>
inline void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  writep(x);
  putchar(' ');
}
template <typename T>
inline void writeln(T x) {
  write(x);
  putchar('\n');
}
using namespace std;
int n, a[200005], tr[200005], sau[200005], sz[200005];
set<pair<int, int> > q;
void setup() {
  read(n);
  for (int i = (1); i <= (n); i++) read(a[i]);
}
void work(int ans = 0, int pos = 0) {
  for (int i = (1); i <= (n + 1); i++)
    if (a[i] != a[i - 1]) {
      tr[i] = pos;
      sau[pos] = i;
      sz[pos] = i - pos;
      pos = i;
    }
  for (int i = (1); i <= (n); i++)
    if (tr[i] || sau[i]) q.insert(make_pair(-sz[i], i));
  while (q.size()) {
    ans++;
    auto it = q.begin();
    int id = (*it).second;
    q.erase(it);
    int s = sau[id], t = tr[id];
    if (s == n + 1 && !t) break;
    tr[s] = t;
    sau[t] = s;
    if (t && s != n + 1 && a[t] == a[s]) {
      q.erase(make_pair(-sz[t], t));
      q.erase(make_pair(-sz[s], s));
      sz[t] = sz[s] + sz[t];
      sau[t] = sau[s];
      tr[sau[s]] = t;
      q.insert(make_pair(-sz[t], t));
    }
  }
  write(ans);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  setup();
  work();
  return 0;
}
