#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=2e5+10,mo=1e9+7;
long long f[N];
int las[N];
int main()
{
	int n;
	scanf("%d",&n);
	f[0]=1;
	for (int i=1;i<=n;i++) 
	{
		int x;
		scanf("%d",&x);
		f[i]=f[i-1];
		if (las[x]&&las[x]<i-1) f[i]=(f[i]+f[las[x]])%mo;
		las[x]=i;
	}
	printf("%lld\n",f[n]);
}