#include <bits/stdc++.h>
const int mod = 1e9 + 7;
const int maxn = 2e5 + 5;
using namespace std;
long long b, n;
int a[maxn];
struct node {
  int l, r, len;
  node *f, *s;
};
struct Node {
  node *p;
  bool operator<(const Node &d) const {
    if (p->len != d.p->len) {
      return p->len > d.p->len;
    } else {
      return p->l < d.p->l;
    }
  }
};
set<Node> st;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  int l = 0, r = 0;
  node *p, *q, *head;
  head = new node;
  head->l = -1;
  head->r = -1;
  head->len = 0;
  p = head;
  for (int i = 1; i < n; i++) {
    if (i != n - 1) {
      if (a[i] == a[i - 1]) {
        r = i;
      } else {
        q = new node;
        q->f = p;
        q->s = NULL;
        q->l = l;
        q->r = r;
        q->len = r - l + 1;
        Node tmp;
        tmp.p = q;
        l = i;
        r = i;
        st.insert(tmp);
        p->s = q;
        p = q;
      }
    } else {
      if (a[i] == a[i - 1]) {
        q = new node;
        q->f = p;
        q->s = NULL;
        q->l = l;
        q->r = i;
        q->len = i - l + 1;
        Node tmp;
        tmp.p = q;
        st.insert(tmp);
        p->s = q;
        p = q;
      } else {
        q = new node;
        q->f = p;
        q->s = NULL;
        q->l = l;
        q->r = r;
        q->len = r - l + 1;
        Node tmp;
        tmp.p = q;
        st.insert(tmp);
        p->s = q;
        p = q;
        q = new node;
        q->f = p;
        q->s = NULL;
        q->l = i;
        q->r = i;
        q->len = 1;
        tmp.p = q;
        st.insert(tmp);
        p->s = q;
        p = q;
      }
    }
  }
  long long ans = 0;
  while (!st.empty()) {
    ans++;
    Node s = *st.begin();
    st.erase(st.begin());
    node *ff, *ss;
    ff = s.p->f;
    ss = s.p->s;
    if (ff == head || ss == NULL) {
      if (ff == head && ss != NULL)
        ff->s = ss, ss->f = head;
      else
        ff->s = NULL;
      continue;
    }
    if (a[ff->r] != a[ss->l]) {
      ff->s = ss;
      ss->f = ff;
    } else {
      s.p = ff;
      st.erase(s);
      s.p = ss;
      st.erase(s);
      node *x = new node;
      x->l = ff->l;
      x->r = ss->r;
      x->f = ff->f;
      x->s = ss->s;
      ff->f->s = x;
      if (ss->s != NULL) ss->s->f = x;
      x->len = ff->len + ss->len;
      Node tmp;
      tmp.p = x;
      st.insert(tmp);
    }
  }
  cout << ans << endl;
  return 0;
}
