#include <bits/stdc++.h>
using namespace std;
template <typename S, typename T>
ostream& operator<<(ostream& out, pair<S, T> const& p) {
  out << '(' << p.first << ", " << p.second << ')';
  return out;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> const& v) {
  long long l = v.size();
  for (long long i = 0; i < l - 1; i++) out << v[i] << ' ';
  if (l > 0) out << v[l - 1];
  return out;
}
template <typename T>
void trace(const char* name, T&& arg1) {
  cout << name << " : " << arg1 << "\n";
}
template <typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  trace(comma + 1, args...);
}
const long long N = 2e5 + 100;
const long long MAX_IND = 2e5 + 10;
long long n, arr[N];
long long bit[2 * N];
map<long long, long long> m, len;
set<pair<long long, long long> > s;
void update(long long ind, long long val) {
  while (ind <= MAX_IND) {
    bit[ind] += val;
    ind += (ind & -ind);
  }
}
long long query(long long ind) {
  long long ans = 0;
  while (ind > 0) {
    ans += bit[ind];
    ind -= (ind & -ind);
  }
  return ans;
}
long long get_left(long long a) {
  long long l = 1, r = a - 1;
  long long mid, ans = -1;
  long long thres = query(a);
  while (l <= r) {
    mid = (l + r) / 2;
    if (query(mid) == thres - 1) {
      ans = mid;
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  return ans;
}
long long get_right(long long a) {
  long long l = a + 1, r = n;
  long long mid, ans = -1;
  long long thres = query(a);
  while (l <= r) {
    mid = (l + r) / 2;
    if (query(mid) >= thres + 1) {
      ans = mid;
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  long long l = 0, r = 0;
  for (long long i = 1; i <= n; i++) {
    if (arr[i] != arr[i - 1]) {
      m[l] = r;
      if (l != 0) {
        update(l, 1);
        auto temp = make_pair(r - l + 1, -l);
        s.insert(temp);
        len[l] = (r - l + 1);
      }
      l = i;
      r = i;
    } else {
      r++;
    }
  }
  m[l] = r;
  update(l, 1);
  auto temp = make_pair(r - l + 1, -l);
  s.insert(temp);
  len[l] = (r - l + 1);
  long long ans = 0;
  while (!s.empty()) {
    auto temp = *s.rbegin();
    ans++;
    s.erase(temp);
    long long l = -temp.second;
    long long r = m[l];
    long long lL = get_left(l);
    if (lL == -1) {
      update(l, -1);
      continue;
    }
    long long rL = m[lL];
    long long lR = get_right(r);
    if (lR == -1) {
      update(l, -1);
      continue;
    }
    long long rR = m[lR];
    update(l, -1);
    if (arr[lL] == arr[lR] and query(lL) > 0 && query(lR) > 0) {
      m[lL] = rR;
      long long len1 = len[lL];
      long long len2 = len[lR];
      auto haha = make_pair(len1, -lL);
      auto lol = make_pair(len2, -lR);
      s.erase(haha);
      s.erase(lol);
      s.insert(make_pair(len1 + len2, -lL));
      update(lR, -1);
      len[lL] = len1 + len2;
    }
  }
  cout << ans << "\n";
}
