Scanf.scanf "%d" (fun n ->
    let c = Array.init (n + 1) (fun i -> if i = 0 then (-1) else Scanf.scanf " %d" (fun c -> c)) in
    let dp = Array.make (n + 1) 0 in
    let asm = Array.make 200001 0 in
    dp.(0) <- 1;
    let (+@) a b = (a + b) mod 1000000007 in

    for i = 1 to n do
        if c.(i) = c.(i - 1) then dp.(i) <- dp.(i - 1) else (
            asm.(c.(i)) <- asm.(c.(i)) +@ dp.(i - 1);
            dp.(i) <- asm.(c.(i))
        )
    done;
    Printf.printf "%d\n" dp.(n)
)