#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

template <int mod>
class ModInt {
public:
    ModInt() {};
    ModInt(long long int n) {num = n % mod;}

    ModInt& operator+=(const ModInt& x) {num += x.num; num %= mod; return *this;}
    ModInt& operator-=(const ModInt& x) {num += mod - x.num; num %= mod; return *this;}
    ModInt& operator*=(const ModInt& x) {num *= x.num; num %= mod; return *this;}
    ModInt& operator/=(const ModInt& x) {return *this *= inv(x);}
    friend ModInt operator+(const ModInt& lhs, const ModInt& rhs) {return lhs.num + rhs.num;}
    friend ModInt operator-(const ModInt& lhs, const ModInt& rhs) {return lhs.num - rhs.num + mod;}
    friend ModInt operator*(const ModInt& lhs, const ModInt& rhs) {return lhs.num * rhs.num;}
    friend ModInt operator/(const ModInt& lhs, const ModInt& rhs) {return lhs * inv(rhs);}

    friend ostream& operator<<(ostream& os, const ModInt& x) {return os << x.num;}
    friend istream& operator>>(istream& is, ModInt& x) {
        long long int tmp;
        is >> tmp;
        x.num = tmp % mod;
        return is;
    }

    explicit operator int() const {return num;}

    static ModInt pow(const ModInt& x, long long int n) {
        ModInt ret = 1;
        ModInt digit = x;
        while (n) {
            if (n & 1) ret *= digit; 
            digit *= digit;
            n >>= 1;
        }
        return ret;
    }

    static ModInt inv(const ModInt& x) {
        if (x.num <= 0) return -1;
        if (x.num <= rsv) return (long long int)factt[x.num] * finvt[x.num-1];
        return pow(x, mod-2);
    }

    static void reserve(int n) {
        if (n <= rsv) return;
        n = min(n, mod-1);
        factt.resize(n+1); finvt.resize(n+1);
        for (int i = rsv+1; i <= n; ++i) factt[i] = (long long int)i * factt[i-1] % mod;
        finvt[n] = (int)inv(factt[n]);
        for (int i = n-1; i >= rsv; --i) finvt[i] = (long long int)(i+1) * finvt[i+1] % mod;
        rsv = n;
    }

    static ModInt fact(int n) {
        if (n < 0) return -1;
        if (n >= mod) return 0;
        if (n <= rsv) return factt[n]; 
        long long int ret = factt.back();
        for (int i = rsv+1; i <= n; ++i) ret = i * ret % mod;
        return ret;
    }

    static ModInt factinv(int n) {
        if (n < 0) return -1;
        if (n <= rsv) return finvt[n];
        return inv(fact(n));
    }

    static ModInt perm(int n, int k) {
        if (n < k || k < 0) return -1;
        return fact(n) * factinv(n-k);
    }
    
    static ModInt comb(int n, int k) {
        if (n < k || k < 0) return -1;
        return fact(n) * factinv(n-k) * factinv(k);
    }

    static ModInt repcomb(int n, int k) {
        return comb(n+k-1, k);
    }

private:
    long long int num;
    static vector<int> factt, finvt;
    static int rsv;
};
template<int mod> vector<int> ModInt<mod>::factt(1, 1);
template<int mod> vector<int> ModInt<mod>::finvt(1, 1);
template<int mod> int ModInt<mod>::rsv = 0;

using mint = ModInt<1000000007>;

int main() {
    int n;
    cin >> n;
    vector<int> c;
    for (int i = 0; i < n; ++i) {
        int t;
        cin >> t;
        if (c.empty() || t != c.back()) {
            c.push_back(t);
        }
    }
    n = c.size();

    map<int, vector<int>> m;
    for (int i = 0; i < n; ++i) {
        m[c[i]].push_back(i);
    }

    vector<ll> p_e(n);
    p_e[0] = 0;
    for (int i = 1; i < n; ++i) {
        if (m[c[i]][0] != i) p_e[i] = p_e[i-1]+1;
        else p_e[i] = p_e[i-1];
    }

    vector<mint> dp(n);
    dp[0] = 1;
    for (int i = 1; i < n; ++i) {
        dp[i] = dp[i-1];
        if (m[c[i]][0] == i) continue;
        auto it = lower_bound(m[c[i]].begin(), m[c[i]].end(), i);
        int b = *(it-1);
        dp[i] += dp[b];
    }

    cout << dp[n-1] << endl;

    return 0;
}


Measured memory_bytes: 25972