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

using namespace std;



typedef unsigned long long ull;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef pair<double, double> pdd;

const ull mod = 1e9 + 7;

#define REP(i,n) for(int i=0;i<(int)n;++i)



//debug

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;



template < typename T >

void vprint(T &v){

	REP(i, v.size()){

		cout << v[i] << " ";

	}

	cout << endl;

}



ll dp[202020];

vector<ll> B;

vector<ll> basho(202020);

vector<ll> G[202020];

ll M;



ll rec(ll i){

	if(dp[i]>-1) return dp[i];

	if(i==M-1) return 1;

	ll res = 0;

	res += rec(i+1);

	res %= mod;

	if(G[B[i]].size()-1==basho[i]){

		1;

	}else{

		ll ne = G[B[i]][basho[i]+1];

		res += rec(ne);

		res %=mod;

	}

	dp[i]= res;

	return res;

}



int main(){

	ll N;

	cin >> N;

	vector<ll> C(N);

	REP(i, N) cin >> C[i];





	B.push_back(C[0]);

	for(int i=1;i<N;i++){

		if(C[i]!=C[i-1]) B.push_back(C[i]);

	}

	M = B.size();



	REP(i, 202020) dp[i] = -1;

	REP(i, M){

		G[B[i]].push_back(i);

		basho[i] = G[B[i]].size()-1;

	}



	/*

	REP(i, 5){

		REP(j, G[i].size()){

			cout << G[i][j] << " ";

		}

		cout << endl;

	}

	*/



	cout << rec(0) << endl;



    return 0;

}

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

using namespace std;



typedef unsigned long long ull;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef pair<double, double> pdd;

//const ull mod = 1e9 + 7;

const ll mod = 1e9 + 7;

#define REP(i,n) for(int i=0;i<(int)n;++i)



// debug

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;



template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){

  os << "(" << v.first << ", " << v.second << ")"; return os;

}

template<class T> ostream& operator << (ostream& os, const vector<T> v){

  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;

}

template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){

  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;

}

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



// conversion number to bit

string num2bit(ll num, ll len){

  string bit = "";

  REP(i, len){

    bit += char('0'+(num>>i & 1));

  }

  return bit;

}



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);



    ll N;

    cin >> N;

    vector<ll> C(N);

    REP(i, N) cin >> C[i];



    vector<ll> D;

    REP(i, N){

    	int j = i;

    	while(j<N && C[i]==C[j]) j++;

    	D.push_back(C[i]);

    	i = j - 1;

    }

    ll M = D.size();

    vector<vector<ll>> pos(202020);

    REP(i, M){

    	pos[D[i]].push_back(i);

    }

    vector<ll> dp(M+1, 0);

    dp[0] = 1;

    REP(i, M){

    	dp[i+1] += dp[i];

    	dp[i+1] %= mod;



    	if(i>0){

    		ll next = lower_bound(pos[D[i-1]].begin(), pos[D[i-1]].end(), i) - pos[D[i-1]].begin();

    		if(next>=(int)pos[D[i-1]].size()) continue;

    		ll next_pos = pos[D[i-1]][next];

    		dp[next_pos+1] += dp[i];

    		dp[next_pos+1] %= mod;

    	}

    }

    cout << dp[M] << endl;

    return 0;

}