#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 7;
int N;
int A[MAXN];
void Input() {
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> A[i];
}
int par[MAXN];
pair<int, int> t[MAXN << 2];
pair<int, int> Merge_Node(const pair<int, int> &x, const pair<int, int> &y) {
  pair<int, int> ans;
  ans = x;
  if (x.first < y.first) ans = y;
  return ans;
}
void Build(int k, int l, int r) {
  if (l > r) return;
  if (l == r) {
    t[k].first = (par[l] < 0) * (-par[l]);
    t[k].second = l;
    return;
  }
  int mid = (l + r) >> 1;
  Build(k << 1, l, mid);
  Build(k << 1 | 1, mid + 1, r);
  t[k] = Merge_Node(t[k << 1], t[k << 1 | 1]);
}
void Upd(int k, int l, int r, const int &pos, const int &val) {
  if (l > r || r < pos || l > pos) return;
  if (l == r && r == pos) {
    t[k].first = val;
    return;
  }
  int mid = (l + r) >> 1;
  Upd(k << 1, l, mid, pos, val);
  Upd(k << 1 | 1, mid + 1, r, pos, val);
  t[k] = Merge_Node(t[k << 1], t[k << 1 | 1]);
}
int root(int u) { return (par[u] < 0) ? u : (par[u] = root(par[u])); }
void Merge(int u, int v) {
  if ((u = root(u)) == (v = root(v))) return;
  if (par[u] > par[v]) swap(u, v);
  par[u] += par[v];
  par[v] = u;
}
int Search_left(int k, int l, int r, const int &pos) {
  if (t[k].first == 0) return -1;
  if (l == r && t[k].first) return t[k].second;
  int mid = (l + r) >> 1;
  if (pos <= mid)
    return Search_left(k << 1, l, mid, pos);
  else {
    int res = Search_left(k << 1 | 1, mid + 1, r, pos);
    if (res == -1) res = Search_left(k << 1, l, mid, pos);
    return res;
  }
}
int Search_right(int k, int l, int r, const int &pos) {
  if (t[k].first == 0) return -1;
  if (l == r && t[k].first) return t[k].second;
  int mid = (l + r) >> 1;
  if (pos > mid)
    return Search_right(k << 1 | 1, mid + 1, r, pos);
  else {
    int res = Search_right(k << 1, l, mid, pos);
    if (res == -1) res = Search_right(k << 1 | 1, mid + 1, r, pos);
    return res;
  }
}
void Init() {
  memset(par, -1, sizeof par);
  for (int i = 1; i < N; i++)
    if (A[i] == A[i + 1]) Merge(i, i + 1);
  Build(1, 1, N);
}
int ans = 0;
void Output() {
  while (t[1].first) {
    ans++;
    int pos = t[1].second;
    Upd(1, 1, N, t[1].second, 0);
    int Left = Search_left(1, 1, N, pos);
    int Right = Search_right(1, 1, N, pos);
    if (Left == -1 || Right == -1) continue;
    if (A[Left] == A[Right]) {
      Merge(Left, Right);
      Upd(1, 1, N, Right, 0);
      Upd(1, 1, N, Left, 0);
      int r = root(Left);
      Upd(1, 1, N, r, -par[r]);
    }
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  Input();
  Init();
  Output();
  return 0;
}
