#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int M=200005,Mod=1e9+7;
int n,A[M],B[M],m=0;
ll pre[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++)
		if(A[i]!=A[i-1])B[++m]=A[i];
	n=m;
	dp[0]=1;
	for(int i=1;i<=n;i++){
		dp[i]=(dp[i-1]+pre[B[i]])%Mod;
		pre[B[i]]=(pre[B[i]]+dp[i-1])%Mod;
	}
	printf("%lld\n",dp[n]);
	return 0;
}
