import scala.collection.mutable
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 map = new mutable.HashMap[Int, ArrayBuffer[Int]]

    for {
      i <- 1 to 200000
    } {
      map(i) = ArrayBuffer()
    }

    for {
      ci <- Cs.zipWithIndex
    } {
      val (c, i) = ci
      val arr = map(c)
      if (arr.nonEmpty && arr.last == i - 1) {
        arr(arr.length - 1) = i
      } else {
        arr += i
      }

    }

    val newMap = map.filter(_._2.length >= 2)

    println(
      newMap.foldLeft(1L) {
        (acc, x) =>
          val arr = x._2
          (acc + ((arr.length * (arr.length-1)) / 2)) % 1000000007
      }
    )
  }
}
