// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;

#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)

#define REP(i,a,b) REPP(i,a,b,1)

#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)

#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) REP(i,0,(int)a-1)

#define FORD(i,a) REV(i,(int)a-1,0)

#define PB push_back

#define POB pop_back

#define MP make_pair

#define FI first

#define SE second

typedef long long ll;

typedef unsigned long long ull;

typedef pair < int , int > pii;

typedef vector < int > vi;

typedef vector < pii > vii;

typedef vector < ll > vl;



const double EPS = 1e-9;

const double PI = acos(-1);

const int INF = 1e9;

const ll MOD = 1e9 + 7;



ll addMod(ll a, ll b){

	return (a+b) % MOD;

}



ll mulMod(ll a, ll b){

	return (a*b) % MOD;

}



ll fast(ll a, ll b){

	if(b == 0) return 1;

	ll tmp = fast(a,b/2);

	tmp = mulMod(tmp, tmp);

	if(b & 1) tmp = mulMod(tmp, a);

	return tmp;

}



/////////////////////////////////////////////////////////



const int N = 2e5;



int n;

int m;

int arr[N + 5];

vi lst[N + 5];

ll dp[N + 5];

int nxt[N + 5];



ll solve(int idx){

	if(idx == m+1){

		return 1;

	}

	ll& ret = dp[idx];

	if(ret != -1) return ret;

	ret = solve(idx+1);

	if(nxt[idx] != -1) ret = addMod(ret, solve(nxt[idx]));

	return ret;

}





int main(){

	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);

	memset(nxt,-1,sizeof nxt);

	m = 0;

	cin >> n;

	int bef = -1;

	int x;

	REP(i,1,n){

		cin >> x;

		if(x != bef){

			arr[++m] = x;

			bef = x;

			lst[x].PB(m);

		}

	}

	REP(i,1,N){

		if(lst[i].size() > 1){

			FOR(j,lst[i].size()-1){

				nxt[lst[i][j]] = lst[i][j+1];

			}

		}

	}

	memset(dp,-1,sizeof dp);

	cout << solve(1) << endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 10.170753006282604x):
#include <bits/stdc++.h>

#define rep(i, l, r) for (register int i = l; i <= r; i++)

#define per(i, r, l) for (register int i = r; i >= l; i--)

#define srep(i, l, r) for (register int i = l; i < r; i++)

#define sper(i, r, l) for (register int i = r; i > l; i--)

#define erep(i, x) for (register int i = h[x]; i; i = e[i].next)

#define erep2(i, x) for (register int& i = cur[x]; i; i = e[i].next)

#define pii pair<int, int>

#define pll pair<ll, ll>

#define pdd pair<double, double>

#define fi first

#define se second

#define ui unsigned int

#define ld long double

#define ll long long int 

#define pb push_back

#define pc putchar

#define lowbit(x) (x & -x)

#define maxr 2000020

#define maxn 400020

#define maxm

#define maxs

#define maxb

#define M 1000000007

#define mo(x) (x = (x >= M) ? (x - M) : x)

#define gc() ((p1 == p2 && (p2 = (p1 = buffer) + fread(buffer, 1, maxr, stdin), p1 == p2)) ? EOF : *p1++)

using namespace std;



char buffer[maxr], *p1, *p2;

template <class T> void read(T& x){

	char ch = gc(); x = 0; bool f = 1;

	while (!('0' <= ch && ch <= '9') && ch != '-') ch = gc();

	if (ch == '-') f = 0, ch = gc();

	while ('0' <= ch && ch <= '9') x = (x << 1) + (x << 3) + ch - '0', ch = gc();

	x = (f) ? x : -x;

}

int _num[20];

template <class T> void write(T x){	

	if (!x) {putchar('0'), putchar('\n'); return;}

	if (x < 0) putchar('-'), x = -x;

	int c = 0;

	while (x) _num[++c] = x % 10, x /= 10;

	while (c) putchar('0' + _num[c--]); 

	putchar('\n');

}



int n, a[maxn], _n, _a[maxn], dp[maxn], c[maxn], pre[maxn];



int main(){

	scanf("%d", &_n); rep(i, 1, _n) scanf("%d", _a + i); 

	rep(i, 1, _n) {

		int now = _a[i]; a[++n] = now;

		while (i <= _n && _a[i] == now) i++; i--;

	}

	

	rep(i, 1, n){

		dp[i] = c[a[i]], pre[i] = pre[i - 1] + dp[i], mo(pre[i]);

		//c[a[i + 1]] += pre[i] + 1, mo(c[a[i + 1]]);

		c[a[i]] += pre[i - 1] + 1, mo(c[a[i]]);

	} 

	printf("%d\n", pre[n] + 1);

	return 0;

}