
// Problem : B2. Painting the Array II
// Contest : Codeforces - Codeforces Round #700 (Div. 1)
// URL : https://codeforces.com/contest/1479/problem/B2
// Memory Limit : 512 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#define ll long long 
#define mp make_pair 
#define f(i,n) for(int i=0;i<n;i++) 
#define F first 
#define S second 
#define pb push_back 

using namespace std;

void test(){
	int n;
	cin>>n;
	int a[n];
	f(i,n)cin>>a[i];
	vector<pair<int,int> > v;
	int prev = a[0];
	int cnt = 1;
	for(int i=1;i<n;i++){
		if(a[i]==prev)cnt++;
		else{
			v.pb({prev,cnt});
			cnt = 1;
			prev = a[i];
		}
	}
	v.pb({prev,cnt});
	
	vector<int> v2;
	for(auto p : v)v2.pb(p.F);
	
	int last[n+1];
	memset(last,-1,sizeof(last));
	
	int lm = -1;
	
	
	int s = 0;
	for(int i=0;i<v2.size();i++){
		int p = v2[i];
		if(last[p]!=-1){
			
			if(last[p]>=lm){
				s--;
				lm = i-1;
			}
			
		}
		last[p] = i;
	}
	int ans = v2.size();
	
	ans = ans + s;
	cout<<ans<<"\n";
	
	// cout		<<s<<"\n";
}

int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	// cin>>tests;
	while(tests--){
		test();
	}
}
	