#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, x, prev = -1, pos = -1;
  cin >> n;
  vector<long long> v, f;
  for (long long i = 0; i < n; i++) {
    cin >> x;
    if (x != prev) {
      v.push_back(x);
      f.push_back(1);
      pos++;
      prev = x;
    } else
      f[pos]++;
  }
  set<tuple<long long, long long, long long> > se;
  set<int> idx;
  for (long long i = 0; i < v.size(); i++) {
    tuple<long long, long long, long long> temp;
    get<0>(temp) = -f[i];
    get<1>(temp) = i;
    get<2>(temp) = v[i];
    se.insert(temp);
    idx.insert(i);
  }
  long long ans = 0;
  while (!se.empty()) {
    ans++;
    auto i = *se.begin();
    long long id = get<1>(i);
    se.erase(i);
    idx.erase(id);
    auto it = idx.lower_bound(id);
    if (it == idx.begin() || it == idx.end()) continue;
    long long i2 = *(it);
    --it;
    long long i1 = *(it);
    if (v[i1] == v[i2]) {
      tuple<long long, long long, long long> temp;
      get<0>(temp) = -f[i1];
      get<1>(temp) = i1;
      get<2>(temp) = v[i1];
      se.erase(temp);
      get<0>(temp) = -f[i2];
      get<1>(temp) = i2;
      get<2>(temp) = v[i2];
      se.erase(temp);
      f[i1] += f[i2];
      get<0>(temp) = -f[i1];
      get<1>(temp) = i1;
      get<2>(temp) = v[i1];
      se.insert(temp);
      idx.erase(i2);
    }
  }
  cout << ans << endl;
  return 0;
}
