import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

long P = 10^^9 + 7;

int[2*10^^5] CS;
long[2*10^^5] MEMO;

void main()
{
    auto N = readln.chomp.to!int;
    foreach (i; 0..N) {
        CS[i] = readln.chomp.to!int;
    }

    int[][(10^^5)*2] acc, lefts;
    foreach_reverse(ii, c; CS[0..N]) {
        int i = ii.to!int;
        if (acc[c].empty) {
            acc[c] ~= i;
        } else if (acc[c][$-1] != i + 1) {
            lefts[i] = acc[c];
            acc[c] ~= i;
        }
    }

    long solve(int i) {
        if (i == N) return 1;
        if (MEMO[i]) return MEMO[i];
        long r = solve(i+1);
        foreach (idx, j; lefts[i]) {
            r = ((r + solve(j)) - (idx == lefts[i].length-1 ? 0 : 1)) % P;
        }
        return MEMO[i] = r;
    }

    writeln(solve(0));
}