#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;

const double PI = acos(-1);

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define peek(x) (*(x).begin())
#define rpeek(x) (*(x).rbegin())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define contain(t, v...) (t.find(v) != t.end())
#define pqmin(x...) priority_queue<x, vector<x>, greater<x> >
#define pqmax(x...) priority_queue<x>
mt19937 mt_gen(chrono::high_resolution_clock::now().time_since_epoch().count());

int gen() {return abs((int)mt_gen());}
int gen(int x) {return gen() % x;}
int bit(ll t, int v) {return (t >> v) & 1;}
int bits(ll x) {return __builtin_popcountll(x);}
ll toggle(ll t, int v) {return t ^ (1ll << v);} 
ll lcm(ll t, ll v) {return t / __gcd(t, v) * v;}
template<typename T> int len(T x) {return x.size();}
template<typename T, typename... V> void tomin(T &t, V... v) {t = min({t, v...});}
template<typename T, typename... V> void tomax(T &t, V... v) {t = max({t, v...});}

void draw(int x) {cerr << x;}
void draw(long x) {cerr << x;}
void draw(long long x) {cerr << x;}
void draw(unsigned x) {cerr << x;}
void draw(unsigned long x) {cerr << x;}
void draw(unsigned long long x) {cerr << x;}
void draw(float x) {cerr << x;}
void draw(double x) {cerr << x;}
void draw(long double x) {cerr << x;}
void draw(char x) {cerr << '\'' << x << '\'';}
void draw(const char *x) {cerr << '\"' << x << '\"';}
void draw(const string &x) {cerr << '\"' << x << '\"';}
void draw(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void draw(const pair<T, V> &x) {cerr << '{'; draw(x.fi); cerr << ','; draw(x.se); cerr << '}';}
template<typename T>
void draw(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), draw(i); cerr << "}";}
void paint() {cerr << "]\n";}
template <typename T, typename... V>
void paint(T t, V... v) {draw(t); if (sizeof...(v)) cerr << ", "; paint(v...);}
#ifdef TANNHA
#define debug(x...) cerr << "[" << #x << "] = ["; paint(x)
#else
#define debug(...)
#endif

const double EPS = 1e-8;
const ll INF = 1e9;
const ll MOD = 1000000007;
const int LN = 2e5 + 8;

int a[LN];
int f[LN];
int g[LN];

void solve(int test_number) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int m = 0;
    for (int i = 1; i <= n; i++) {
        if (i == 1 || a[i] != a[i - 1]) {
            a[++m] = a[i];
        }
    }
    n = m;
    f[0] = 1;
    for (int i = 1; i <= n; i++) {
        f[i] = (f[i - 1] + g[a[i]]) % MOD;
        g[a[i]] = (g[a[i]] + f[i - 1]) % MOD;
    }
    cout << f[n];
}

void initialize() {}

void initialize(int test_number) {}

void solve() {
    initialize();
    int test = 1; if (1 & 0) cin >> test;
    for (int i = 1; i <= test; i++) {
        initialize(i);
        solve(i);
    }
}

int main(int argc, char *argv[]) {
    #ifdef TANNHA
    auto start = chrono::steady_clock::now();
    freopen(".inp", "r", stdin); freopen(".out", "w", stdout); solve();
    fprintf(stderr, "\n[%.3f s]\n", chrono::duration<double>(chrono::steady_clock::now() - start).count());
    #else
    solve();
    #endif
    return 0;
}


Measured memory_bytes: 2560