import scala.io.StdIn._
object Main extends App {

  val n = readInt()
  val lastFound= Array.tabulate(2 * 100000){_ ⇒ -1}
  val next = Array.tabulate(n){_ ⇒ 0}
  val colors = Array.tabulate(n){_ ⇒ readInt - 1}
  for (i ← colors.indices.reverse){
    next(i) = lastFound(colors(i))
    lastFound(colors(i)) = i
  }
  val memo = Array.tabulate(n){_ ⇒ -1L}
  val mod = 1000000007L
  for (i ← memo.indices.reverse) solve(i, memo)
  println(
    solve(0, memo)
  )

  def solve(position: Int, memo: Array[Long]): Long = {
    if (position < memo.length){
      if (memo(position) == -1){
        memo(position) = 0
        if (next(position) != -1 && next(position) != position + 1) {
          memo(position) += solve(next(position), memo)
        }
        memo(position) += solve(position + 1, memo)
      }
      memo(position) %= mod
      memo(position)
    }else 1L
  }
}