import java.util.Scanner

import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def removeDup(C: Array[Int]): Array[Int] = {
    val newC = new mutable.MutableList[Int]
    var prev = -1
    for (i <- C.indices) {
      if (C(i) != prev) {
        newC += C(i)
      }
      prev = C(i)
    }
    newC.toArray
  }

  def solve(sc: Scanner): String = {
    val N = sc.nextInt
    val C = removeDup(Array.fill(N)(sc.nextInt))
    //println(C.mkString(","))

    val A = ArrayBuffer.fill(C.length + 1)(1L)
    for (i <- (C.length - 3) to 0 by -1) {
      A(i) = A(i + 1)
      var j = i + 2
      while (j < C.length && C(i) != C(j)) j += 1
      if (j != C.length) {
        A(i) += A(j)
        A(i) %= 1000000007
      }
//      Range(i + 2, C.length).find(j => C(i) == C(j)).foreach { j =>
//        n += A(j)
//        n %= 1000000007
//      }
      //println("A(" + i + ") = " + A(i))
    }

    A(0).toString
  }
}
