#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

class mint {
public:
    long long x;

    constexpr mint(long long x = 0) : x((x % MOD + MOD) % MOD) {}

    constexpr mint operator-() const {
        return mint(-x);
    }

    constexpr mint &operator+=(const mint &a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }

    constexpr mint &operator-=(const mint &a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }

    constexpr mint &operator*=(const mint &a) {
        (x *= a.x) %= MOD;
        return *this;
    }

    constexpr mint operator+(const mint &a) const {
        mint res(*this);
        return res += a;
    }

    constexpr mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }

    constexpr mint operator*(const mint &a) const {
        mint res(*this);
        return res *= a;
    }

    [[nodiscard]] constexpr mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    [[nodiscard]] constexpr mint inv() const {
        return pow(MOD - 2);
    }

    mint &operator/=(mint a) {
        return *this *= a.inv();
    }

    mint operator/(const mint a) const {
        return mint(*this) /= a;
    }

    constexpr bool operator==(const mint &a) const noexcept {
        return this->x == a.x;
    }

    constexpr bool operator!=(const mint &a) const noexcept {
        return this->x != a.x;
    }

    bool operator<(const mint &a) const noexcept {
        return this->x < a.x;
    }

    bool operator>(const mint &a) const noexcept {
        return this->x < a.x;
    }

    bool operator<=(const mint &a) const noexcept {
        return this->x <= a.x;
    }

    bool operator>=(const mint &a) const noexcept {
        return this->x >= a.x;
    }

    friend istream &operator>>(istream &is, mint &a) {
        is >> a.x;
        return is;
    }

    friend ostream &operator<<(ostream &os, const mint &a) {
        return os << a.x;
    }
};

void Main() {
    ll N;
    cin >> N;
    vector<mint> C(N);
    rep(i, N) cin >> C[i];
    vector<mint> dp(N + 1, 0);
    dp[0] = 1;
    map<mint, ll> pos;
    rep(i, N) {
        pos[C[i].x] = -1;
    }
    rep(i, N) {
        mint c = C[i];
        if (pos[c] != -1 && i > pos[c] + 1) {
            dp[i + 1] += dp[pos[c] + 1];
        }
        dp[i + 1] += dp[i];
        pos[c] = i;
    }
    cout << dp[N] << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 15872