#include <bits/stdc++.h>
using namespace std;
void readi(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
void readll(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
void readc(char &x) {
  char c;
  while ((c = getchar()) == ' ')
    ;
  x = c;
}
void writes(string s) { puts(s.c_str()); }
void writeln() { writes(""); }
void writei(int x) {
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
void writell(long long x) {
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
long long qp(long long x, long long y) {
  if (y == 0) return 1;
  if (y == 1) return x;
  long long z = qp(x, y / 2);
  z = z * z % 1000000007;
  if (y & 1) z = z * x % 1000000007;
  return z;
}
deque<pair<int, int> > dq, nxt;
int n, m, i, j, x, ans, lngest;
int main() {
  ios::sync_with_stdio(false);
  ;
  cin >> n >> x;
  dq.push_back(make_pair(x, 1));
  for (i = 1; i < n; i++) {
    cin >> x;
    if (dq.back().first == x)
      dq.back().second++;
    else
      dq.push_back(make_pair(x, 1));
  }
  while (!dq.empty()) {
    nxt.clear();
    lngest = 0;
    for (i = 0; i < dq.size(); i++) lngest = max(lngest, dq[i].second);
    while (!dq.empty()) {
      if (dq.front().second >= lngest) {
        dq.pop_front();
        ans++;
        if (!nxt.empty() && !dq.empty() &&
            nxt.back().first == dq.front().first) {
          dq.front().second += nxt.back().second;
          nxt.pop_back();
        }
      } else {
        nxt.push_back(dq.front());
        dq.pop_front();
      }
    }
    dq = nxt;
  }
  cout << ans;
  return 0;
}
