#include<iostream>
#include<stdio.h>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
#include<deque>
#include<utility>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

const int N = 1e5 + 5;
int ar[N], pt[N];
bool cek[N];

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for(int i = 1; i <= n; ++i)cin >> ar[i];
    vector<int> v;
    for(int i = 1; i <= n; ++i){
        if(ar[i] != ar[i - 1])v.pb(ar[i]);
    }
    vector<ii> lst;
    for(int i = 1; i <= n; ++i)pt[i] = -1;
    for(int i = 0; i < v.size(); ++i){
        lst.pb(mp(v[i], pt[v[i]]));
        pt[v[i]] = i;
    }
    int cnt = 0;
    int idx = 0;
    for(int i = 0; i < lst.size(); ++i){
        if(lst[i].se != -1 && !cek[lst[i].se]){
            for(int j = idx; j < i - 1; ++j){
                if(j == lst[i].se)continue;
                cek[j] = true;
                ++cnt;
            }
            //cnt += i - idx - 2;
            idx = i - 1;
        }
        //cout << cnt << ' ' << idx << endl;
    }
    cout << cnt + lst.size() - idx << endl;
    return 0;
}
