local n = io.read("n")
local colpos, col, dp= {}, {}, {}
local last = -1
mof = 1000000000+7
for i = 1, n do
    local x = io.read("n")
    if last ~= x then
        col[#col+1] = x
        dp[#col] = {0, 0}
        colpos[x] = colpos[x] or {head = 1}
        colpos[x][#colpos[x] + 1] = #col
        last = x
    end
end
n = #col
dp[1][1] = 1
for i = 1, n do
    local x = col[i]
    local last_pos = colpos[x][colpos[x].head]
    -- update break now
    dp[i][1] = dp[i][1] + dp[last_pos][2]
    -- update break next
    if i < n then
        dp[i+1][1] = dp[i+1][1] + dp[i][1]
    end
    -- update keep going begin
    dp[i][2] = dp[last_pos][2] + dp[i][1] -- from hitory or from now

    dp[i][1] = dp[i][1] % mof
    dp[i][2] = dp[i][2] % mof
    if last_pos ~= i then
        colpos[x].head = colpos[x].head + 1
    end
    --print(string.format("dp[%d] = {%d,%d}; col = %d", i,dp[i][1],dp[i][2], col[i]))
end
print(dp[n][1])