#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
int n, a[maxn], tot, col[maxn], sum[maxn], pre[maxn], nxt[maxn], ans;
bool vis[maxn];
priority_queue<pair<int, int> > q;
int main() {
  ios ::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  reverse(a + 1, a + n + 1);
  for (int i = 1; i <= n; ++i)
    if (a[i] == a[i - 1])
      ++sum[tot];
    else
      col[++tot] = a[i], sum[tot] = 1;
  for (int i = 1; i <= tot; ++i)
    pre[i] = i - 1, nxt[i] = i + 1, q.push(make_pair(sum[i], i));
  while (!q.empty()) {
    int cur = q.top().second;
    q.pop();
    if (vis[cur]) continue;
    int l = pre[cur], r = nxt[cur];
    pre[r] = l, nxt[l] = r, vis[cur] = true;
    if (l and col[l] == col[r])
      vis[r] = true, pre[nxt[r]] = l, nxt[l] = nxt[r], sum[l] += sum[r],
      q.push(make_pair(sum[l], l));
    ++ans;
  }
  cout << ans << endl;
}
