#include<bits/stdc++.h>
#define P 1000000007
using namespace std;
int f[220000],sum[220000];
int a[220000];
int n;
int main(){
	scanf("%d",&n);
	f[0]=1;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		f[i]=f[i-1];
		if(a[i]!=a[i-1])(f[i]+=sum[a[i]])%=P;
		if(a[i]!=a[i-1])(sum[a[i]]=f[i])%=P;
	}
	printf("%d\n",f[n]);
}