program prob6
    implicit none
    integer(8), parameter :: ma = 200005
    integer(8), parameter :: mo = 1000000007
    integer(8) :: n, i
    integer(8), allocatable :: c(:)
    integer(8) :: pre(ma)
    integer(8), allocatable :: dp(:)

    read(*,*) n
    allocate(c(n), dp(0:n))

    do i = 1, n
        read(*,*) c(i)
    end do

    dp(0) = 0
    dp(1) = 1
    do i = 1, ma
        pre(i) = 0
    end do
    pre(c(1)) = 1
    do i = 2, n
        if(c(i) == c(i-1)) then
            dp(i) = dp(i-1)
            pre(c(i)) = i
        else
            dp(i) = mod(dp(i-1) + dp(pre(c(i))), mo)
            pre(c(i)) = i
        end if
    end do

    write(*,*) dp(n)
    deallocate(dp, c)

    stop
contains
end program prob6