// Original C++ solution (slower):
#include <iostream>

#include <sstream>

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <ctime>

#include <cstring>

#include <string>

#include <vector>

#include <stack>

#include <queue>

#include <deque>

#include <map>

#include <set>

#include <bitset>

#include <numeric>

#include <utility>

#include <iomanip>

#include <algorithm>

#include <functional>

#include <unordered_map>

using namespace std;



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

#define ALL(v) (v.begin(), v.end())

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)



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

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

template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)

{ return s << '<' << P.first << ", " << P.second << '>'; }

template<class T> ostream& operator << (ostream &s, vector<T> P)

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

template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)

{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

template<class T> ostream& operator << (ostream &s, set<T> P)

{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }

template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)

{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }





const long long MOD = 1000000007;

int N;

vector<int> c;



vector<int> last[210000];

long long dp[210000];





int main() {

    while (cin >> N) {

        c.resize(N);

        for (int i = 0; i < N; ++i) cin >> c[i];



        for (int i = 0; i < 210000; ++i) last[i].clear();

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

            last[c[i]].push_back(i);

        }



        memset(dp, 0, sizeof(dp));

        dp[0] = 1;

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

            //cout << i << ": " << dp[i] << endl;

            if (i == N) continue;

            

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



            int color = c[i];

            int it = lower_bound(last[color].begin(), last[color].end(), i)

                - last[color].begin();



            if (it + 1 < last[color].size()) {

                int j = last[color][it + 1];

                if (j - i > 1) {

                    dp[j] += dp[i]; dp[j] %= MOD;

                }

            }

        }

        cout << dp[N] << endl;

    }

}


// Optimized solution to the same problem (faster):
#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

const long long MOD = 1000000007;



vector<int> places[210000];

long long dp[210000];

void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }



int main() {

    // 入力

    int N; cin >> N;

    vector<int> c(N);

    for (int i = 0; i < N; ++i) cin >> c[i];



    // places[i] := (c[j] = i となるような j の集まり)

    for (int i = 0; i < 210000; ++i) places[i].clear();

    for (int i = 0; i < N; ++i) places[c[i]].push_back(i);



    // DP

    dp[0] = 1;

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

        // 特に操作しない場合

        add(dp[i+1], dp[i]);



        // 操作する場合

        int color = c[i];

        int it = lower_bound(places[color].begin(), places[color].end(), i)

            - places[color].begin(); // c[i] が color 色の何番目の要素か

        if (it > 0) {

            int j = places[color][it - 1]; // c[j] = c[i] となる j

            if (i - j > 1) add(dp[i+1], dp[j+1]);

        }

    }

    cout << dp[N] << endl;

}


// Fastest known solution for this problem: