local N = io.read("n")
local C = {}
for i=1,N do
    C[i] = io.read("n")
end

local dp = {}
local last_pos = {}
dp[0] = 1
for i=1,N do
    if C[i] == C[i-1] then
        -- No stone between i-1 and i
        dp[i] = dp[i-1]
    else
        local c = C[i]
        if last_pos[c] then
            -- Stones from (last_pos[c], i) are reversible.
            -- Not reverse: dp[i-1]
            -- Reverse: dp[last_pos[c]]
            dp[i] = dp[i-1] + dp[last_pos[c]]
        else
            -- Can't reverse stone because this is first appearance of c
            dp[i] = dp[i-1]
        end
        last_pos[c] = i
    end
    --print(i,C[i],dp[i])
end
print(dp[N])
