#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, val, cnt, y, sz;
  node *l, *r;
  int maxcnt, maxx;
  node(int _val, int _cnt, int _x) {
    y = RAND_MAX * rand() + rand();
    l = r = nullptr;
    val = _val;
    cnt = _cnt;
    x = _x;
    maxcnt = cnt;
    maxx = x;
    sz = 1;
  }
};
void update(node *&t) {
  if (t == nullptr) return;
  t->maxcnt = t->cnt;
  t->maxx = t->x;
  if (t->l != nullptr && t->l->maxcnt >= t->maxcnt) {
    t->maxcnt = t->l->maxcnt;
    t->maxx = t->l->maxx;
  }
  if (t->r != nullptr && t->r->maxcnt > t->maxcnt) {
    t->maxcnt = t->r->maxcnt;
    t->maxx = t->r->maxx;
  }
  t->sz = 1;
  if (t->l != nullptr) t->sz += t->l->sz;
  if (t->r != nullptr) t->sz += t->r->sz;
}
int tsz(node *t) { return (t != nullptr ? t->sz : 0); }
node *merge(node *a, node *b) {
  if (a == nullptr) return b;
  if (b == nullptr) return a;
  if (a->y > b->y) {
    a->r = merge(a->r, b);
    update(a);
    return a;
  } else {
    b->l = merge(a, b->l);
    update(b);
    return b;
  }
}
pair<node *, node *> split(node *t, int x) {
  if (t == nullptr) return {t, t};
  if (t->x < x) {
    auto p = split(t->r, x);
    t->r = p.first;
    update(t);
    return {t, p.second};
  } else {
    auto p = split(t->l, x);
    t->l = p.second;
    update(t);
    return {p.first, t};
  }
}
pair<node *, node *> splitsz(node *t, int k) {
  if (t == nullptr || k == 0) return {nullptr, t};
  int lsz = tsz(t->l);
  if (k == t->sz) {
    return {t, nullptr};
  } else if (k <= lsz) {
    auto p = splitsz(t->l, k);
    t->l = p.second;
    update(t);
    return {p.first, t};
  } else {
    auto p = splitsz(t->r, k - lsz - 1);
    t->r = p.first;
    update(t);
    return {t, p.second};
  }
}
void add(node *&t, int val, int cnt, int x) {
  auto p = split(t, x);
  t = merge(p.first, merge(new node(val, cnt, x), p.second));
}
void delmax(node *&t) {
  int maxx = t->maxx;
  auto p = split(t, maxx);
  auto p1 = split(p.second, maxx + 1);
  auto L = p.first;
  auto R = p1.second;
  if (L != nullptr && R != nullptr) {
    auto lp = splitsz(L, tsz(L) - 1);
    auto rp = splitsz(R, 1);
    if (lp.second->val == rp.first->val) {
      auto M = new node(lp.second->val, lp.second->cnt + rp.first->cnt,
                        lp.second->x);
      t = merge(lp.first, merge(M, rp.second));
    } else {
      t = merge(merge(lp.first, lp.second), merge(rp.first, rp.second));
    }
  } else {
    t = merge(L, R);
  }
}
void print(node *t) {
  if (t != nullptr) {
    print(t->l);
    cout << '+' << t->val << ' ' << t->cnt << ' ' << t->x << '+' << endl;
    print(t->r);
  }
}
int n;
vector<int> a;
int solve() {
  node *t = nullptr;
  int lastval = -1;
  int lastidx = -1;
  int lastcnt = 0;
  for (int i = 0; i < (n); i++) {
    int val;
    val = a[i];
    if (val != lastval) {
      if (lastval != -1) {
        add(t, lastval, lastcnt, lastidx);
      }
      lastidx++;
      lastcnt = 1;
      lastval = val;
    } else {
      lastcnt++;
    }
  }
  add(t, lastval, lastcnt, lastidx);
  int ans = 0;
  while (t != nullptr) {
    delmax(t);
    ++ans;
  }
  return ans;
}
int main() {
  srand(1337);
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n;
  a.resize(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  cout << solve();
  return 0;
}
