#ifndef NOBITS
#include <bits/stdc++.h>
#endif
using namespace std;




#ifdef LOCAL
#include "/home/aravinda/cp/snippets/debug/deb.cpp"
#else 
#define deb(...) ;
#endif
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forr(i, ct) for (auto& i : ct)
#define forkv(k, v, ct) for (auto& [k, v] : ct)
#define trav(it, ct) for(auto it = ct.begin(); it != ct.end(); ++it)
#define endl "\n"
#define ctvl(a, v) {auto b = &a[0]; fill_n(b, sizeof(a)/sizeof(*b), v);}
#define ctvl2(a, v) {auto b = &a[0][0]; fill_n(b, sizeof(a)/sizeof(*b), v);}
#define sz(x) ((int)(x).size())
#define sqr(x) ((x)*(x))
#define pb  push_back
#define mp make_pair
#define reint(...) int __VA_ARGS__; read(__VA_ARGS__);
#define restring(...) string __VA_ARGS__; read(__VA_ARGS__);
#define relong(...) long long __VA_ARGS__; read(__VA_ARGS__);
#define redouble(...) double __VA_ARGS__; read(__VA_ARGS__);
#define revec(n, x) vector<int> x(n); for(auto& i : x) { cin >> i; }
#define renvec(n, x) reint(n) revec(n, x)
#define if0(t) if(!(t))
template<typename ...Args> void read(Args&... args) { (cin >> ... >> args); }
template <typename...Args> void writeln(const Args &... args) { ((cout << args << " "), ...), cout << endl; }
template <typename...Args> void write(const Args &... args) { ((cout << args), ...), cout << endl; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T> typename enable_if<is_same<decltype(declval<T>().size()), size_t>::value, int>::type operator~(const T& ct) { return (int)ct.size(); }
#define Fn(name, ret, ...)      function<ret(__VA_ARGS__)> name = [&](__VA_ARGS__)->ret
template <typename T, typename... Args> bool ckmax(T &a, const Args&... b) { return (a < max({b...})) ? (a = max({b...}), true) : false; }
template <typename T, typename... Args> bool ckmin(T &a, const Args&... b) { return (a > min({b...})) ? (a = min({b...}), true) : false; }
template <typename T> struct range {
    T u, v; bool inclusive;
    range(const T& _u, const T& _v, const bool& _inclusive = false) : u(_u), v(_v), inclusive(_inclusive) {}
    bool has(const T& w) { return (u <= w) and (inclusive ? (w <= v) : (w < v)); }
};
// #define int long long 

using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vvi = vector<vector<int>>;
using vpii = vector<pii>;
using uint = unsigned;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using max_heap = priority_queue<T, vector<T>, less<T>>;

const int N = 200'010;
const ll mod = 1e9 + 7;
auto soln() {
    renvec(n, A);
    n = unique(all(A)) - A.begin();
    deb(A);
    vll dp(n + 1, 1);
    map<ll, ll> pref;
    for (int i = n - 1; i >= 0; --i) {
        dp[i] = (dp[i + 1] + pref[A[i]]) % mod;
        pref[A[i]] = (pref[A[i]] + dp[i + 1]) % mod;
    }
    cout << dp[0] << endl;
}
signed main() {
    int t = 1;
#ifndef LOCAL
    { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); }
#endif
    // cin >> t;
    while (t--)
        soln();
    return 0;
}



Measured memory_bytes: 17928