#include<iostream>
using namespace std;
long mod=1e9+7,dp[2<<17];
int c[2<<17],pr[2<<17];
int main()
{
	int n;cin>>n;
	dp[0]=1;
	for(int i=0;i++<n;)
	{
		int C;cin>>C;
		dp[i]=dp[i-1]+(pr[C]!=0&&pr[C]<i-1?dp[pr[C]]:0);
		dp[i]%=mod;
		pr[C]=i;
	}
	cout<<dp[n]<<endl;
}