#include<bits/stdc++.h>
#define ll long long
#define Mod 1000000007
#define M 200005
using namespace std;
int n,A[M],las[M],W[M],dp[M];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	for(int i=1;i<=n;i++){
		las[i]=W[A[i]];
		W[A[i]]=i;
//		cerr<<i<<" "<<las[i]<<endl;
	}
	dp[0]=1;
	for(int i=1;i<=n;i++){
		dp[i]=dp[i-1];
		if(las[i]&&i-las[i]>1){
			dp[i]=(dp[i]+dp[las[i]])%Mod;
		}
	}
	printf("%d\n",dp[n]);
	return 0;
}