#include<cstdio>
#include<algorithm>

using namespace std;

#define N 100001

int a[N],f[N]; 

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	int tag=0,x; 
	for(int i=1;i<=n;++i) f[i]=1e5+1;
	int ans=1e5+1;
	for(int i=1;i<=n;++i)
	{
		x=min(ans+1,f[a[i]])+tag;
		if(a[i]!=a[i-1]) tag++;
		f[a[i-1]]=min(f[a[i-1]],x-tag);
		ans=min(ans,f[a[i-1]]); 
	}
	printf("%d",ans+tag);
}
