#include<bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int maxn = 240000;
constexpr LL mod = 1000000007;
int c[maxn], p[maxn], f[maxn];
int main(){
	int n, m = 0;
	scanf("%d", &n);
	for(int i = 1; i <= n; i += 1) scanf("%d", c + i);
	for(int i = 1; i <= n; i += 1) if(c[i] != c[i - 1]) c[m += 1] = c[i];
	f[0] = 1;
	for(int i = 1; i <= m; i += 1) f[i] = p[c[i]] = (p[c[i]] + f[i - 1]) % mod;
	printf("%d", f[m]);
}