import scala.collection.mutable.ArrayBuffer

object Main {

  val amari = 1000000007

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N = sc.nextInt()
    val Cs = Array.fill(N)(sc.nextInt())
    val len = Cs.length

    val res: ArrayBuffer[Long] = ArrayBuffer.fill(Cs.length)(1L)

    for (i <- (len-2) to 0 by -1) {
      run(i)
    }

    println(res(0))

    def run(i: Int): Unit = {
      val s = Cs(i)
      var j = i+2
      var r = 0L
      while(j < len) {
        if (s == Cs(j)) {
          while(j < len && s == Cs(j)) j = j+1
          if (j < len)
            r = (r + res(j)) % amari
          else
            r = (r + 1) % amari
        } else {
          j = j +1
        }
      }
      res(i) = res(i+1) + r
    }
  }
}
