#include <bits/stdc++.h>
using namespace std;
int long long n, p, l, r, cnt, i, ans, j;
set<pair<int long long, pair<int long long, int long long> > > q;
pair<pair<int long long, int long long>, pair<int long long, int long long> >
    d[300005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> p;
  l = 1, r = 1;
  for (i = 2; i <= n; i++) {
    int long long x;
    cin >> x;
    if (p != x) {
      d[l] = {{(r - l + 1), p}, {l, r}};
      d[r] = {{(r - l + 1), p}, {l, r}};
      q.insert({-1 * (r - l + 1), {l, r}});
      l = i;
      r = i;
    } else
      r++;
    p = x;
  }
  d[0] = {{0, -1e9}, {0, 0}};
  d[n + 1] = {{0, 1e9}, {n + 1, n + 1}};
  q.insert({-1 * (r - l + 1), {l, r}});
  d[l] = {{(r - l + 1), p}, {l, r}};
  d[r] = {{(r - l + 1), p}, {l, r}};
  while (!q.empty()) {
    int long long l = q.begin()->second.first;
    int long long r = q.begin()->second.second;
    ans++;
    q.erase(q.begin());
    if (d[l - 1].first.second == d[r + 1].first.second) {
      q.erase({-1 * d[l - 1].first.first,
               {d[l - 1].second.first, d[l - 1].second.second}});
      q.erase({-1 * d[r + 1].first.first,
               {d[r + 1].second.first, d[r + 1].second.second}});
      int long long c = d[l - 1].first.first + d[r + 1].first.first;
      d[d[l - 1].second.first] = {
          {c, d[l - 1].first.second},
          {d[l - 1].second.first, d[r + 1].second.second}};
      d[d[r + 1].second.second] = {
          {c, d[l - 1].first.second},
          {d[l - 1].second.first, d[r + 1].second.second}};
      q.insert({-1 * (c), {d[l - 1].second.first, d[r + 1].second.second}});
    } else {
      if (r < n) {
        int long long z = d[r + 1].second.second;
        q.erase(
            {d[z].first.first * -1, {d[z].second.first, d[z].second.second}});
        q.erase({d[r + 1].first.first * -1, {d[r + 1].second.first, z}});
        d[z] = {{d[r + 1].first.first, d[r + 1].first.second}, {l, z}};
        d[l] = d[z];
        q.insert(
            {d[z].first.first * -1, {d[z].second.first, d[z].second.second}});
      }
      if (l > 1 && r == n) {
        int long long z = d[l - 1].second.first;
        q.erase(
            {d[z].first.first * -1, {d[z].second.first, d[z].second.second}});
        q.erase({d[l - 1].first.first * -1, {z, d[l - 1].second.second}});
        d[z] = {{d[l - 1].first.first, d[l - 1].first.second}, {z, r}};
        d[r] = d[z];
        q.insert(
            {d[z].first.first * -1, {d[z].second.first, d[z].second.second}});
      }
    }
  }
  cout << ans << endl;
}
