#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
const int N = 200005;
int n, s[N];
int las[N], nex[N];
int ans = 0, dp[N];
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) {
		scanf("%d", s+i);
		nex[las[s[i]]] = i;
		las[s[i]] = i;
	}
	dp[1] = 1;
	for(int i = 1; i < n; ++i) {
		dp[i + 1] = (dp[i + 1] + dp[i]) % mod;
		if(nex[i] != i+1) dp[nex[i]] = (dp[nex[i]] + dp[i]) % mod;
	}
	printf("%d\n", dp[n]);
	return 0;
}