//
//  main.cpp
//
//
//  Created by ji luyang on 2020/12/22.
//

#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <time.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <unordered_set>
#include <set>
#include <map>
using namespace std;
int t;
int n;
int a[100010], nxt[100010];
vector<int> g[100010];
int f(vector<int>& v) {
    int n = v.size(), res = 0;
    for (int i = 0; i < n; i++) {
        if (!i || a[v[i]] != a[v[i - 1]]) res++;
    }
    return res;
}
void solve() {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) {
        g[a[i]].push_back(i);
    }
    for (int i = 1; i <= n; i++) {
        if (g[i].empty()) continue;
        for (int j = 0; j < g[i].size(); j++) {
            nxt[g[i][j]] = (j == g[i].size() - 1 ? 1e9 : g[i][j + 1]);
        }
    }
    vector<int> v1, v2;
    for (int i = 1; i <= n; i++) {
        if (v1.empty()) {
            v1.push_back(i);
            continue;
        }
        if (v2.empty()) {
            if (a[v1.back()] == a[i]) v1.push_back(i);
            else v2.push_back(i);
            continue;
        }
        if (a[v1.back()] == a[i]) v1.push_back(i);
        else if (a[v2.back()] == a[i]) v2.push_back(i);
        else {
            if (nxt[v1.back()] < nxt[v2.back()]) v2.push_back(i);
            else v1.push_back(i);
        }
    }
    cout << f(v1) + f(v2);
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    //cin >> t;
    //while (t--) {
        solve();
    //}
    return 0;
}
