#include<bits/stdc++.h>

using namespace std;

#define fr(i, n) for(int i = 0; i < n; i++)
#define frr(i, n) for(int i = 1; i <= n; i++)
#define frm(i, n) for(int i = n-1; i >= 0; i--)

#define pb push_back
#define f first
#define s second

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<vector<ll>> matrix;

#define mem(v, k) memset(v, k, sizeof(v));
#define db cout << "Debug" << endl;
#define all(x) begin(x), end(x)
#define dbg(x)  cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define mp make_pair
#define pq priority_queue

#define mx(a, b) a = max(a, b);
#define mod(a, b) a = a%b;

#define MAXN 100010
#define MOD 1000000007
#define MAXL 30
#define ROOT 1
#define INF 1000000000000000100

int dp[MAXN];
vector<int> b;
int a[MAXN], previous[MAXN], ap[MAXN];
int n;

int main(){
	fastio;
	cin >> n;
	frr(i, n) cin >> a[i];

	b.pb(a[1]);
	for(int i = 2; i <= n; i++){
		if(a[i] != b.back()) b.pb(a[i]);
	}

	n = (int)b.size();

	frr(i, n) a[i] = b[i-1];

	frr(i, n){
		if(ap[a[i]] == 0){
			previous[i] = -1;
			ap[a[i]] = i;
		}
		else{
			previous[i] = ap[a[i]];
			ap[a[i]] = i;
		}
	}

	frr(i, n){
		if(previous[i] == -1) dp[i] = dp[i-1] + 1;
		else{
			dp[i] = min(dp[i-1] + 1, dp[previous[i] + 1] + (i - previous[i] - 2));
		}
	}

	cout << dp[n] << endl;
}
