object Main {
  def main(args: Array[String]): Unit = {
    val Array(n, m, d) = readLine.split(" ").map(_.toInt)
    val c = readLine.split(" ").zipWithIndex.map{ case (x, i) => (i+1, x.toInt) }.toList
    val sc = c.foldLeft(0){ case (s, (_, v)) => s + v }
    f1(n, d, c, sc) match {
      case None => println("NO")
      case Some(l) => {
        println("YES")
        println(l.mkString(" "))
      }
    }
  }

  def f1(n: Int, d: Int, c: List[(Int, Int)], sc: Int): Option[List[Int]] = {
    if (d - 1 + sc >= n) {
      Some(c.map{ case (i, ni) => List.fill(ni)(i) }.foldLeft(List.fill(n - sc)(0)){ case (li, lj) => li ++ lj })
    } else {
      c match {
        case Nil => None
        case (i, ni) :: rc => f1(n - (ni + d - 1), d, rc, (sc - ni)) match {
          case Some(l) => Some(List.fill(d - 1)(0) ++ List.fill(ni)(i) ++ l)
          case None => None
        }
      }
    }
  }

}

import java.util.Scanner

import scala.language.postfixOps

object TaskC extends App {
  val sc = new Scanner(System.in)
  val (n, m, d) = (sc.nextInt, sc.nextInt, sc.nextInt)

  var w = 0
  val platforms = (1 to m).map(_ => sc.nextInt).zipWithIndex.reverse.map { case (c, ind) =>
    val platform = (n - w - c + 1, c, ind + 1)
    w += c
    platform
  }.reverse.toArray

  var last = 0

  0 until m foreach { i =>
    if (platforms(i)._1 - last > d) {
      platforms(i) = (last + d, platforms(i)._2, platforms(i)._3)
    }
    last = platforms(i)._1 + platforms(i)._2 - 1
  }

  val out = if (n - last + 1 <= d) {
    val water = Array.fill(n)(0)
    platforms.foreach { case (i, c, l) =>
      i until (i + c) foreach (j => water(j - 1) = l)
    }
    s"YES\n${water.mkString(" ")}"
  } else {
    "NO"
  }

  println(out)
}


object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, x) = in.next().split(' ').map(_.toInt)

  val (sweetl, candyl) = (1 to n).foldLeft((List.empty[(Int, Int)], List.empty[(Int, Int)])) {
    case ((s, c), _) =>

      val Array(t, h, m) = in.next().split(' ').map(_.toInt)
      t match {
        case 0 => (s, (h, m) :: c)
        case _ => ((h, m) :: s, c)
      }
  }

  def calc(isCandyl: Boolean): Int = {
    val sweet = sweetl.toArray
    val candy = candyl.toArray
    var work = true
    var count = 0
    var possibleh = x
    var isCandy = isCandyl

    while (work) {
      if (isCandy) {
        val index = candy.indices.foldLeft(-1) {
          case (-1, i) if candy(i)._1 <= possibleh && candy(i)._2 > 0 => i
          case (j, i)  if candy(i)._1 <= possibleh && j >= 0 && candy(i)._2 > candy(j)._2 => i
          case (j, i) => j
        }
        work = index != -1

        if (work) {
          possibleh += candy(index)._2
          candy(index) = (0, 0)
        }

      } else {
        val index = sweet.indices.foldLeft(-1) {
          case (-1, i) if sweet(i)._1 <= possibleh && sweet(i)._2 > 0 => i
          case (j, i)  if sweet(i)._1 <= possibleh && j >= 0 && sweet(i)._2 > sweet(j)._2 => i
          case (j, i) => j
        }
        work = index != -1
        if (work) {
          possibleh += sweet(index)._2
          sweet(index) = (0, 0)
        }
      }
      if (work) count += 1
//      println(candy.mkString(" "))
//      println(sweet.mkString(" "))
      isCandy = !isCandy
    }
    count
  }
//  println(candyl)
//  println(sweetl)
//  println(calc(true))
//  println(calc(false))
  println(Math.max(calc(true), calc(false)))
}

import java.util.Scanner

/**
 * Created by hama_du on 2014/06/19.
 */
object ProblemA extends App {
  def solve(jump: Int, caramel: Array[(Int,Int,Boolean)], fruit:Array[(Int,Int,Boolean)], want: Int): Int = {
    if (want == 0) {
      val idx = selectAvailable(jump, caramel)
      if (idx == -1) {
        return 0
      }
      val gain = caramel(idx)._2
      caramel(idx) = (0, 0, true)
      solve(jump + gain, caramel, fruit, 1-want) + 1
    } else {
      val idx = selectAvailable(jump, fruit)
      if (idx == -1) {
        return 0
      }
      val gain = fruit(idx)._2
      fruit(idx) = (0, 0, true)
      solve(jump + gain, caramel, fruit, 1-want) + 1
    }
  }

  def selectAvailable(jump: Int, candies: Array[(Int,Int,Boolean)]): Int = {
    val available = candies.zipWithIndex.filter(ci => ci._1._1 <= jump && !ci._1._3 )
    if (available.size == 0) {
      -1
    } else {
      available.maxBy(ci => ci._1._2)._2
    }
  }

  val in = new Scanner(System.in)
  val n,x = in.nextInt()
  val candies = (0 until n).map(_ => {
    (in.nextInt(), in.nextInt(), in.nextInt())
  })
  val answer = (0 to 1).map(start => {
    // (height, mass, eaten)
    val caramel = candies.filter(c => c._1 == 0).map(c => (c._2, c._3, false)).toArray
    val fruit = candies.filter(c => c._1 == 1).map(c => (c._2, c._3, false)).toArray
    solve(x, caramel, fruit, start)
  }).max
  println(answer)
}

/**
 * I've tried to make this piece of code as readable as possible.
 * Enjoy hacking it!
 */
import scala.collection._

object A extends App {

  def tokenizeLine = new java.util.StringTokenizer(readLine)
  def readInts(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toInt) }

  val Array(n, x) = readInts(2)
  val _as = mutable.ArrayBuffer.empty[(Int, Int)]
  val _bs = mutable.ArrayBuffer.empty[(Int, Int)]

  for (i <- 0 until n) {
    val Array(t, h, m) = readInts(3)
    if (t == 0) {
      _as += ((h, m))
    } else {
      _bs += ((h, m))
    }
  }

  val as = _as.sortBy(_._2)
  val bs = _bs.sortBy(_._2)

  def calc(prev0: Boolean): Int = {
    val aUsed = Array.fill(n)(false)
    val bUsed = Array.fill(n)(false)
    var ai = 0
    var bi = 0
    var h = x
    var count = 0
    var prev = prev0
    var choice = 0
    while (choice >= 0 && ((prev && ai < as.size) || (!prev && bi < bs.size))) {
      choice = -1
      if (prev) {
        for (i <- as.indices) if (!aUsed(i) && as(i)._1 <= h) choice = i
        if (choice >= 0) {
          h += as(choice)._2
          aUsed(choice) = true
          ai += 1
          count += 1
        }
      } else {
        for (i <- bs.indices) if (!bUsed(i) && bs(i)._1 <= h) choice = i
        if (choice >= 0) {
          h += bs(choice)._2
          bUsed(choice) = true
          bi += 1
          count += 1
        }
      }
      prev = !prev
    }
    count
  }

  println(calc(true) max calc(false))
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, x) = in.next().split(' ').map(_.toInt)
  val (sweetl, candyl) = (1 to n).foldLeft((List.empty[(Int, Int)], List.empty[(Int, Int)])) {
    case ((s, c), _) =>

      val Array(t, h, m) = in.next().split(' ').map(_.toInt)
      t match {
        case 0 => (s, (h, m) :: c)
        case _ => ((h, m) :: s, c)
      }
  }
  val sweet = sweetl.toArray
  val candy = candyl.toArray

  var isCandy = !sweet.exists{ case(h, m) => h <= x && m > 0} ||
    (candy.exists{ case(h, m) => h <= x && m > 0 } && candy.filter{case(h, m) => h <= x && m > 0}.maxBy(_._2)._2
      > sweet.filter{case(h, m) => h <= x && m > 0}.maxBy(_._2)._2)

  var work = true
  var count = 0
  var possibleh = x

  while (work) {
    if (isCandy) {
      val index = candy.indices.foldLeft(-1) {
        case (-1, i) if candy(i)._1 <= possibleh && candy(i)._2 > 0 => i
        case (j, i)  if candy(i)._1 <= possibleh && j > 0 && candy(i)._2 > candy(j)._2 => i
        case (j, i) => j
      }
      work = index != -1

      if (work) {
        possibleh += candy(index)._2
        candy(index) = (0, 0)
      }

    } else {
      val index = sweet.indices.foldLeft(-1) {
        case (-1, i) if sweet(i)._1 <= possibleh && sweet(i)._2 > 0 => i
        case (j, i)  if sweet(i)._1 <= possibleh && j > 0 && sweet(i)._2 > sweet(j)._2 => i
        case (j, i) => j
      }
      work = index != -1
      if (work) {
        possibleh += sweet(index)._2
        sweet(index) = (0, 0)
      }
    }
    if (work) count += 1
    isCandy = !isCandy
  }
  println(count)
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, x) = in.next().split(' ').map(_.toInt)

  val (sweetl, candyl) = (1 to n).foldLeft((List.empty[(Int, Int)], List.empty[(Int, Int)])) {
    case ((s, c), _) =>

      val Array(t, h, m) = in.next().split(' ').map(_.toInt)
      t match {
        case 0 => (s, (h, m) :: c)
        case _ => ((h, m) :: s, c)
      }
  }

  def calc(isCandyl: Boolean): Int = {
    val sweet = sweetl.toArray
    val candy = candyl.toArray
    var work = true
    var count = 0
    var possibleh = x
    var isCandy = isCandyl

    while (work) {
      if (isCandy) {
        val index = candy.indices.foldLeft(-1) {
          case (-1, i) if candy(i)._1 <= possibleh && candy(i)._2 > 0 => i
          case (j, i)  if candy(i)._1 <= possibleh && j > 0 && candy(i)._2 > candy(j)._2 => i
          case (j, i) => j
        }
        work = index != -1

        if (work) {
          possibleh += candy(index)._2
          candy(index) = (0, 0)
        }

      } else {
        val index = sweet.indices.foldLeft(-1) {
          case (-1, i) if sweet(i)._1 <= possibleh && sweet(i)._2 > 0 => i
          case (j, i)  if sweet(i)._1 <= possibleh && j > 0 && sweet(i)._2 > sweet(j)._2 => i
          case (j, i) => j
        }
        work = index != -1
        if (work) {
          possibleh += sweet(index)._2
          sweet(index) = (0, 0)
        }
      }
      if (work) count += 1
      isCandy = !isCandy
    }
    count
  }

  println(Math.max(calc(true), calc(false)))
}


object E3{
  def main(args: Array[String]){
   import scala.collection.mutable.PriorityQueue
    import scala.collection.mutable.ArrayBuffer
    import util.control.Breaks._
//    var in=io.Source.stdin.getLines()
    import java.io.{PrintWriter}
    import java.util.{Locale, Scanner}

    val in = new Scanner(System.in)
    val out = new PrintWriter(System.out)

    def nextInt = in.nextInt
    def nextLong = in.nextLong
    def nextDouble = in.nextDouble
    def nextString = in.next

    val n=nextInt

    val m=nextInt
    val U=new Array[Int](m)
    val V=new Array[Int](m)
    val W=new Array[Long](m)
    for(i <- 0 until m)
    {
      U(i)=nextInt
      V(i)=nextInt
      W(i)=nextLong
    }

    var edgeof =Array.fill(n+1)(new ArrayBuffer[(Int,Long)]())
    for(i<-0 until U.length){
      edgeof(U(i))+=((V(i),W(i)));
      edgeof(V(i))+=((U(i),W(i)));
    }
    val d=Array.fill(n+1)(Long.MaxValue)
    val u0=nextInt
    val q = new PriorityQueue[(Long,Int)]()(Ordering.by((t:(Long,Int))=> -t._1))

    d(u0)=0
    q.enqueue((d(u0),u0))
    val mark=Array.fill(n+1)(false)
    while(!q.isEmpty){
      breakable{
        val u=q.dequeue._2
        if(mark(u)){
          break
        }
        mark(u)=true
        for(p<-edgeof(u)){
          if(d(p._1)>d(u)+p._2){
            d(p._1)=d(u)+p._2
            q.enqueue((d(p._1),p._1))
          }
        }
      }
    }

    var sum=0L
    val selectedEdge=Array.fill(n+1)(-1)
    for(i<-0 until U.length){
      if(d(U(i))==d(V(i))+W(i) && (selectedEdge(U(i))== -1 || (W(selectedEdge(U(i)))>W(i)))){
        selectedEdge(U(i))=i

      }
      if(d(V(i))==d(U(i))+W(i) && (selectedEdge(V(i))== -1 || (W(selectedEdge(V(i))))>W(i))){
        selectedEdge(V(i))=i

      }

    }

    for(i<-1 to n if i != u0){ sum+=W(selectedEdge(i))}
    out.println(sum)
    for(i<-1 to n if i != u0){ out.print((selectedEdge(i)+1)+" ")}
    out.println()
    out.flush
    out.close

  }
}

object E3{
  def main(args: Array[String]){
   import scala.collection.mutable.PriorityQueue
    import scala.collection.mutable.ArrayBuffer
    import util.control.Breaks._
//    var in=io.Source.stdin.getLines()
    import java.io.{PrintWriter}
    import java.util.{Locale, Scanner}

    val in = new Scanner(System.in)
    val out = new PrintWriter(System.out)

    def nextInt = in.nextInt
    def nextLong = in.nextLong
    def nextDouble = in.nextDouble
    def nextString = in.next

    val n=nextInt

    val m=nextInt
    val U=new Array[Int](m)
    val V=new Array[Int](m)
    val W=new Array[Long](m)
    for(i <- 0 until m)
    {
      U(i)=nextInt
      V(i)=nextInt
      W(i)=nextLong
    }

    var edgeof =Array.fill(n+1)(new ArrayBuffer[(Int,Long)]())
    for(i<-0 until U.length){
      edgeof(U(i))+=((V(i),W(i)));
      edgeof(V(i))+=((U(i),W(i)));
    }
    val d=Array.fill(n+1)(Long.MaxValue)
    val u0=nextInt
    val q = new PriorityQueue[(Long,Int)]()(Ordering.by((t:(Long,Int))=> -t._1))

    d(u0)=0
    q.enqueue((d(u0),u0))
    val mark=Array.fill(n+1)(false)
    while(!q.isEmpty){
      breakable{
        val u=q.dequeue._2
        if(mark(u)){
          break
        }
        mark(u)=true
        for(p<-edgeof(u)){
          if(d(p._1)>d(u)+p._2){
            d(p._1)=d(u)+p._2
            q.enqueue((d(p._1),p._1))
          }
        }
      }
    }

    var sum=0L
    val selectedEdge=Array.fill(n+1)(-1)
    for(i<-0 until U.length){
      if(d(U(i))==d(V(i))+W(i) && (selectedEdge(U(i))== -1 || (W(selectedEdge(U(i)))>W(i)))){
        selectedEdge(U(i))=i

      }
      if(d(V(i))==d(U(i))+W(i) && (selectedEdge(V(i))== -1 || (W(selectedEdge(V(i))))>W(i))){
        selectedEdge(V(i))=i

      }

    }

    for(i<-1 to n if i != u0){ sum+=W(selectedEdge(i))}
    out.println(sum)
    for(i<-1 to n if i != u0){ out.print((selectedEdge(i)+1)+" ") }
    out.println()
    out.flush
    out.close

  }
}

import scala.collection._
import scala.math.Ordering

object Solution extends App {
  import ContestLib._
  val Array(n, m) = readIntArray()
  var weight = Array.fill(m){0}
  val data = Range(0, m).foldLeft(Array.fill(n)(mutable.ListBuffer.empty[(Int, Int, Int)])) {
    case(acc, el) =>
      val Array(u, v, w) = readIntArray()
      weight(el) = w
      acc(u - 1) += ((v - 1, w, el))
      acc(v - 1) += ((u - 1, w, el))
      acc
  }

  val visited = Array.fill(n)(false)
  val start = readInt() - 1
  var expand = data(start).foldLeft(mutable.PriorityQueue.empty[(Int, Long, Int, Int)](SecondOrdering)) {
    case (acc, (u, w, edge)) =>
      acc.enqueue((u, w, edge, weight(edge)))
      acc
  }
  visited(start) = true
  val edges = mutable.ListBuffer.empty[Int]
  val ex = Array.fill(n)(-1l)
  ex(start) = 0

  while (expand.nonEmpty) {
    val (u, w, edge, _) = expand.dequeue()
    if (!visited(u)) {
      visited(u) = true
      edges += edge
      data(u).foreach { case(u1, w1, edge1) =>
        if (!visited(u1))
        if (ex(u1) == -1 || ex(u1) >= w + w1){
          ex(u1) = w + w1
          expand.enqueue((u1, w + w1, edge1, weight(edge1)))
        }
      }
    }
  }

  val sum = edges.foldLeft(0l) {
    case(acc, el) => acc + weight(el)
  }

  println(sum)
  println(edges.map(_ + 1).mkString(" "))

}

object ContestLib {
  import scala.io.StdIn._
  def readIntArray() = readLine().split(' ').map(_.toInt)
  def readInt() = scala.io.StdIn.readInt()

  def SecondOrdering[T1, T2, T3, T4](implicit ord1: Ordering[T1],
                                 ord2: Ordering[T2],
                                 ord3: Ordering[T3],
                                 ord4: Ordering[T4]
                                  ): Ordering[(T1, T2, T3, T4)]  =
    new Ordering[(T1, T2, T3, T4)]{
      def compare(x: (T1, T2, T3, T4), y: (T1, T2, T3, T4)): Int = {
        var res = -ord2.compare(x._2, y._2)
        if (res == 0)
          res = -ord4.compare(x._4, y._4)
        res
      }

  }
}

object E3{
  def main(args: Array[String]){
   import scala.collection.mutable.PriorityQueue
    import scala.collection.mutable.ArrayBuffer
    import util.control.Breaks._
//    var in=io.Source.stdin.getLines()
    import java.io.{PrintWriter}
    import java.util.{Locale, Scanner}

    val in = new Scanner(System.in)
    val out = new PrintWriter(System.out)

    def nextInt = in.nextInt
    def nextLong = in.nextLong
    def nextDouble = in.nextDouble
    def nextString = in.next

    val n=nextInt

    val m=nextInt
    val U=new Array[Int](m)
    val V=new Array[Int](m)
    val W=new Array[Long](m)
    for(i <- 0 until m)
    {
      U(i)=nextInt
      V(i)=nextInt
      W(i)=nextLong
    }

    var edgeof =Array.fill(n+1)(new ArrayBuffer[(Int,Long)]())
    for(i<-0 until U.length){
      edgeof(U(i))+=((V(i),W(i)));
      edgeof(V(i))+=((U(i),W(i)));
    }
    val d=Array.fill(n+1)(Long.MaxValue)
    val u0=nextInt
    val q = new PriorityQueue[(Long,Int)]()(Ordering.by((t:(Long,Int))=> -t._1))

    d(u0)=0
    q.enqueue((d(u0),u0))
    val mark=Array.fill(n+1)(false)
    while(!q.isEmpty){
      breakable{
        val u=q.dequeue._2
        if(mark(u)){
          break
        }
        mark(u)=true
        for(p<-edgeof(u)){
          if(d(p._1)>d(u)+p._2){
            d(p._1)=d(u)+p._2
            q.enqueue((d(p._1),p._1))
          }
        }
      }
    }

    var sum=0L
    val selectedEdge=Array.fill(n+1)(-1)
    for(i<-0 until U.length){
      if(d(U(i))==d(V(i))+W(i) && (selectedEdge(U(i))== -1 || (W(selectedEdge(U(i)))>W(i)))){
        selectedEdge(U(i))=i

      }
      if(d(V(i))==d(U(i))+W(i) && (selectedEdge(V(i))== -1 || (W(selectedEdge(V(i))))>W(i))){
        selectedEdge(V(i))=i

      }

    }

    for(i<-1 to n if i != u0){ sum+=W(selectedEdge(i))}
    out.println(sum)
    for(i<-1 to n if i != u0){ out.print((selectedEdge(i)+1));out.print(" ") }
    out.println()
    out.flush
    out.close

  }
}

import scala.collection._
import scala.math.Ordering

object Solution extends App {
  import ContestLib._
  val Array(n, m) = readIntArray()
  var weight = Array.fill(m){0}
  val data = Range(0, m).foldLeft(Array.fill(n)(mutable.ListBuffer.empty[(Int, Int, Int)])) {
    case(acc, el) =>
      val Array(u, v, w) = readIntArray()
      weight(el) = w
      acc(u - 1) += ((v - 1, w, el))
      acc(v - 1) += ((u - 1, w, el))
      acc
  }

  val visited = Array.fill(n)(false)
  val start = readInt() - 1
  var expand = data(start).foldLeft(mutable.PriorityQueue.empty[(Int, Long, Int, Int)](SecondOrdering)) {
    case (acc, (u, w, edge)) =>
      acc.enqueue((u, w, edge, weight(edge)))
      acc
  }
  visited(start) = true
  val edges = mutable.ListBuffer.empty[Int]
  val ex = Array.fill(n)(-1l)
  ex(start) = 0

  while (expand.nonEmpty) {
    val (u, w, edge, _) = expand.dequeue()
    if (!visited(u)) {
      visited(u) = true
      edges += edge
      data(u).foreach { case(u1, w1, edge1) =>
        if (!visited(u1))
        if (ex(u1) == -1 || ex(u1) >= w + w1){
          ex(u1) = w + w1
          expand.enqueue((u1, w + w1, edge1, weight(edge1)))
        }
      }
    }
  }

  val sum = edges.foldLeft(0) {
    case(acc, el) => acc + weight(el)
  }

  println(sum)
  println(edges.mkString(" "))

}

object ContestLib {
  import scala.io.StdIn._
  def readIntArray() = readLine().split(' ').map(_.toInt)
  def readInt() = scala.io.StdIn.readInt()

  def SecondOrdering[T1, T2, T3, T4](implicit ord1: Ordering[T1],
                                 ord2: Ordering[T2],
                                 ord3: Ordering[T3],
                                 ord4: Ordering[T4]
                                  ): Ordering[(T1, T2, T3, T4)]  =
    new Ordering[(T1, T2, T3, T4)]{
      def compare(x: (T1, T2, T3, T4), y: (T1, T2, T3, T4)): Int = {
        var res = -ord2.compare(x._2, y._2)
        if (res == 0)
          res = -ord4.compare(x._4, y._4)
        res
      }

  }
}

import scala.collection._
import scala.math.Ordering

object Solution extends App {
  import ContestLib._
  val Array(n, m) = readIntArray()
  var weight = Array.fill(m){0}
  val data = Range(0, m).foldLeft(Array.fill(n)(mutable.ListBuffer.empty[(Int, Int, Int)])) {
    case(acc, el) =>
      val Array(u, v, w) = readIntArray()
      weight(el) = w
      acc(u - 1) += ((v - 1, w, el))
      acc(v - 1) += ((u - 1, w, el))
      acc
  }

  val visited = Array.fill(n)(false)
  val start = readInt() - 1
  var expand = data(start).foldLeft(mutable.PriorityQueue.empty[(Int, Long, Int, Int)](SecondOrdering)) {
    case (acc, (u, w, edge)) =>
      acc.enqueue((u, w, edge, weight(edge)))
      acc
  }
  visited(start) = true
  val edges = mutable.ListBuffer.empty[Int]
  val ex = Array.fill(n)(-1l)
  ex(start) = 0

  while (expand.nonEmpty) {
    val (u, w, edge, _) = expand.dequeue()
    if (!visited(u)) {
      visited(u) = true
      edges += (edge + 1)
      data(u).foreach { case(u1, w1, edge1) =>
        if (!visited(u1))
        if (ex(u1) == -1 || ex(u1) >= w + w1){
          ex(u1) = w + w1
          expand.enqueue((u1, w + w1, edge1, weight(edge1)))
        }
      }
    }
  }

  val sum = edges.foldLeft(0) {
    case(acc, el) => acc + weight(el)
  }

  println(sum)
  println(edges.mkString(" "))

}

object ContestLib {
  import scala.io.StdIn._
  def readIntArray() = readLine().split(' ').map(_.toInt)
  def readInt() = scala.io.StdIn.readInt()

  def SecondOrdering[T1, T2, T3, T4](implicit ord1: Ordering[T1],
                                 ord2: Ordering[T2],
                                 ord3: Ordering[T3],
                                 ord4: Ordering[T4]
                                  ): Ordering[(T1, T2, T3, T4)]  =
    new Ordering[(T1, T2, T3, T4)]{
      def compare(x: (T1, T2, T3, T4), y: (T1, T2, T3, T4)): Int = {
        var res = -ord2.compare(x._2, y._2)
        if (res == 0)
          res = -ord4.compare(x._4, y._4)
        res
      }

  }
}

import scala.collection._
import scala.math.Ordering

object Solution extends App {
  import ContestLib._
  val Array(n, m) = readIntArray()
  var weight = Map.empty[Int, Int]
  val data = Range(1, m + 1).foldLeft(Array.fill(n)(mutable.Set.empty[(Int, Int, Int)])) {
    case(acc, el) =>
      val Array(u, v, w) = readIntArray()
      weight += (el -> w)
      acc(u - 1) += ((v - 1, w, el))
      acc(v - 1) += ((u - 1, w, el))
      acc
  }
  val visited = Array.fill(n)(false)
  val start = readInt()
  var expand = data(0).foldLeft(mutable.PriorityQueue.empty[(Int, Int, Int)](SecondOrdering)) {
    case (acc, (u, w, edge)) =>
      acc.enqueue((u, w, edge))
      acc
  }
  visited(0) = true
  var edges = Set.empty[Int]

  while (expand.nonEmpty) {
    val (u, w, edge) = expand.dequeue()
    if (!visited(u)) {
      visited(u) = true
      edges += edge
      data(u).foreach { case(u1, w1, edge1) =>
        if (!visited(u1)) expand.enqueue((u1, w + w1, edge1))
      }
    }
  }

  val sum = edges.foldLeft(0) {
    case(acc, el) => acc + weight(el)
  }

  println(sum)
  println(edges.mkString(" "))

}

object ContestLib {
  import scala.io.StdIn._
  def readIntArray() = readLine().split(' ').map(_.toInt)
  def readInt() = scala.io.StdIn.readInt()

  def SecondOrdering[T1, T2, T3](implicit ord1: Ordering[T1],
                                 ord2: Ordering[T2],
                                 ord3: Ordering[T3]
                                  ): Ordering[(T1, T2, T3)]  =
    new Ordering[(T1, T2, T3)]{
      def compare(x: (T1, T2, T3), y: (T1, T2, T3)): Int =
        -ord2.compare(x._2, y._2)

  }
}

import scala.collection._
import scala.math.Ordering

object Solution extends App {
  import ContestLib._
  val Array(n, m) = readIntArray()
  var weight = Array.fill(m){0}
  val data = Range(0, m).foldLeft(Array.fill(n)(mutable.ListBuffer.empty[(Int, Int, Int)])) {
    case(acc, el) =>
      val Array(u, v, w) = readIntArray()
      weight(el) = w
      acc(u - 1) += ((v - 1, w, el))
      acc(v - 1) += ((u - 1, w, el))
      acc
  }

  val visited = Array.fill(n)(false)
  val start = readInt() - 1
  var expand = data(start).foldLeft(mutable.PriorityQueue.empty[(Int, Long, Int, Int)](SecondOrdering)) {
    case (acc, (u, w, edge)) =>
      acc.enqueue((u, w, edge, weight(edge)))
      acc
  }
  visited(start) = true
  val edges = mutable.ListBuffer.empty[Int]
  val ex = Array.fill(n)(-1l)
  ex(start) = 0

  while (expand.nonEmpty) {
    val (u, w, edge, _) = expand.dequeue()
    if (!visited(u)) {
      visited(u) = true
      edges += edge
      data(u).foreach { case(u1, w1, edge1) =>
        if (!visited(u1))
        if (ex(u1) == -1 || ex(u1) >= w + w1){
          ex(u1) = w + w1
          expand.enqueue((u1, w + w1, edge1, weight(edge1)))
        }
      }
    }
  }

  val sum = edges.foldLeft(0) {
    case(acc, el) => acc + weight(el)
  }

  println(sum)
  println(edges.map(_ + 1).mkString(" "))

}

object ContestLib {
  import scala.io.StdIn._
  def readIntArray() = readLine().split(' ').map(_.toInt)
  def readInt() = scala.io.StdIn.readInt()

  def SecondOrdering[T1, T2, T3, T4](implicit ord1: Ordering[T1],
                                 ord2: Ordering[T2],
                                 ord3: Ordering[T3],
                                 ord4: Ordering[T4]
                                  ): Ordering[(T1, T2, T3, T4)]  =
    new Ordering[(T1, T2, T3, T4)]{
      def compare(x: (T1, T2, T3, T4), y: (T1, T2, T3, T4)): Int = {
        var res = -ord2.compare(x._2, y._2)
        if (res == 0)
          res = -ord4.compare(x._4, y._4)
        res
      }

  }
}

import scala.collection._
import scala.math.Ordering

object Solution extends App {
  import ContestLib._
  val Array(n, m) = readIntArray()
  var weight = Map.empty[Int, Int]
  val data = Range(1, m + 1).foldLeft(Array.fill(n)(mutable.Set.empty[(Int, Int, Int)])) {
    case(acc, el) =>
      val Array(u, v, w) = readIntArray()
      weight += (el -> w)
      acc(u - 1) += ((v - 1, w, el))
      acc(v - 1) += ((u - 1, w, el))
      acc
  }

  val visited = Array.fill(n)(false)
  val start = readInt() - 1
  var expand = data(start).foldLeft(mutable.PriorityQueue.empty[(Int, Int, Int, Int)](SecondOrdering)) {
    case (acc, (u, w, edge)) =>
      acc.enqueue((u, w, edge, weight(edge)))
      acc
  }
  visited(start) = true
  val edges = mutable.ListBuffer.empty[Int]
  val exWeights = mutable.Map.empty[Int, Int]
  val ex = Array.fill(n)(-1)
  ex(start) = 0

  while (expand.nonEmpty) {
    val (u, w, edge, _) = expand.dequeue()
    if (!visited(u)) {
      visited(u) = true
      edges += edge
      data(u).foreach { case(u1, w1, edge1) =>
        if (!visited(u1) && (ex(u1) == -1 || ex(u1) > w + w1)) {
          ex(u1) = w + w1
          expand.enqueue((u1, w + w1, edge1, weight(edge1)))
        }
      }
    }
  }

  val sum = edges.foldLeft(0) {
    case(acc, el) => acc + weight(el)
  }

  println(sum)
  println(edges.mkString(" "))

}

object ContestLib {
  import scala.io.StdIn._
  def readIntArray() = readLine().split(' ').map(_.toInt)
  def readInt() = scala.io.StdIn.readInt()

  def SecondOrdering[T1, T2, T3, T4](implicit ord1: Ordering[T1],
                                 ord2: Ordering[T2],
                                 ord3: Ordering[T3],
                                 ord4: Ordering[T4]
                                  ): Ordering[(T1, T2, T3, T4)]  =
    new Ordering[(T1, T2, T3, T4)]{
      def compare(x: (T1, T2, T3, T4), y: (T1, T2, T3, T4)): Int = {
        val res = -ord2.compare(x._2, y._2)
        if (res == 0)
          return -ord4.compare(x._4, y._4)
        res
      }

  }
}

import scala.collection._

object Solution extends App {
  import ContestLib._
  val Array(n, m) = readIntArray()
  var weight = Map.empty[Int, Int]
  val data = Range(1, m + 1).foldLeft(Array.fill(n)(mutable.Set.empty[(Int, Int, Int)])) {
    case(acc, el) =>
      val Array(u, v, w) = readIntArray()
      weight += (el -> w)
      acc(u - 1) += ((v - 1, w, el))
      acc(v - 1) += ((u - 1, w, el))
      acc
  }
  val visited = Array.fill(n)(false)
  val start = readInt()
  var expand = data(0).foldLeft(SortedMap.empty[Int, (Int, Int)]) {
    case (acc, (u, w, edge)) => acc + (u -> (w, edge))
  }
  visited(0) = true
  var edges = Set.empty[Int]

  while (expand.nonEmpty) {
    val (u, (w, edge)) = expand.head
    expand = expand.tail
    if (!visited(u)) {
      visited(u) = true
      edges += edge
      data(u).foreach { case(u1, w1, edge1) =>
        if (!visited.contains(u1) || (!expand.contains(u1) || (expand(u1)._1 > w + w1))) {
          expand += (u1 -> (w + w1, edge1))
        }
      }
    }
  }

  val sum = edges.foldLeft(0) {
    case(acc, el) => acc + weight(el)
  }

  println(sum)
  println(edges.mkString(" "))

}

object ContestLib {
  import scala.io.StdIn._
  def readIntArray() = readLine().split(' ').map(_.toInt)
  def readInt() = scala.io.StdIn.readInt()
}

import scala.collection._
import scala.math.Ordering

object Solution extends App {
  import ContestLib._
  val Array(n, m) = readIntArray()
  var weight = Map.empty[Int, Int]
  val data = Range(1, m + 1).foldLeft(Array.fill(n)(mutable.Set.empty[(Int, Int, Int)])) {
    case(acc, el) =>
      val Array(u, v, w) = readIntArray()
      weight += (el -> w)
      acc(u - 1) += ((v - 1, w, el))
      acc(v - 1) += ((u - 1, w, el))
      acc
  }
  val visited = Array.fill(n)(false)
  val start = readInt()
  var expand = data(0).foldLeft(mutable.PriorityQueue.empty[(Int, Int, Int)](SecondOrdering)) {
    case (acc, (u, w, edge)) =>
      acc += ((u, w, edge))
  }
  visited(0) = true
  var edges = Set.empty[Int]

  while (expand.nonEmpty) {
    val (u, w, edge) = expand.head
    expand = expand.tail
    if (!visited(u)) {
      visited(u) = true
      edges += edge
      data(u).foreach { case(u1, w1, edge1) =>
        if (!visited.contains(u1)) expand += ((u1, w + w1, edge1))
      }
    }
  }

  val sum = edges.foldLeft(0) {
    case(acc, el) => acc + weight(el)
  }

  println(sum)
  println(edges.mkString(" "))

}

object ContestLib {
  import scala.io.StdIn._
  def readIntArray() = readLine().split(' ').map(_.toInt)
  def readInt() = scala.io.StdIn.readInt()

  def SecondOrdering[T1, T2, T3](implicit ord1: Ordering[T1],
                                 ord2: Ordering[T2],
                                 ord3: Ordering[T3]
                                  ): Ordering[(T1, T2, T3)]  =
    new Ordering[(T1, T2, T3)]{
      def compare(x: (T1, T2, T3), y: (T1, T2, T3)): Int = {
        val compare2 = ord2.compare(x._2, y._2)
        if (compare2 != 0) return compare2
        0
      }

  }
}

object E{
   object Edge {
      def apply(s:String): Edge={
        val t=s.split(" ")
        Edge(u=t(0).toInt,v=t(1).toInt,w=t(2).toInt)
      }
    }
    case class Edge(u: Int, v: Int, w: Int)
  def main(args: Array[String]){

    import scala.collection.mutable.ArrayBuffer
    var in=io.Source.stdin.getLines()
    val t=in.next().split(" ")
    val n=t(0).toInt
    val m=t(1).toInt
    val edge={for(_<-1 to m) yield Edge(in.next())}.toArray

    var edgeof =Array.fill(n+1)(new ArrayBuffer[Int]())
    for(i<-0 until edge.length){
      edgeof(edge(i).u)+=i;
      edgeof(edge(i).v)+=i;
    }
    val d=Array.fill(n+1)(Int.MaxValue)
    val u0=in.next().toInt
    val q = new scala.collection.mutable.Queue[Int]
    val selectedEdge=Array.fill(n+1)(-1)
    q+=u0
    d(u0)=0

    while(!q.isEmpty){
      val u=q.dequeue
      for(i<-edgeof(u)){
        var p=edge(i).u
        if(u==p){
          p=edge(i).v
        }
        if(d(p)>d(u)+edge(i).w){
          d(p)=d(u)+edge(i).w
          if(!q.exists(_ == p)){
            q+=p
          }
          selectedEdge(p)=i
        }
        else if(d(p)==d(u)+edge(i).w){
          if(edge(selectedEdge(p)).w>edge(i).w){
            selectedEdge(p)=i
          }
        }
      }
    }
    var sum=0
    for(i<-1 until n if i != u0){ sum+=edge(selectedEdge(i)).w}
    println(sum)
    for(i<-1 until n if i != u0){ print(selectedEdge(i)+1);print (' ')}
  }
}

object E{
  def main(args: Array[String]){
    println("good here")
  }
}

object Etest{
  case class Edge(u: Int, v: Int, w: Int)

object Edge {
  def apply(s:String): Edge={
    val t=s.split(" ")
    Edge(u=t(0).toInt,v=t(1).toInt,w=t(2).toInt)
  }
}

  def main(args: Array[String]){
    println("good here")
  }
}

object E2{
   object Edge {
      def apply(s:String): Edge={
        val t=s.split(" ")
        Edge(u=t(0).toInt,v=t(1).toInt,w=t(2).toInt)
      }
    }
    case class Edge(u: Int, v: Int, w: Int)
  def main(args: Array[String]){
   import scala.collection.mutable.PriorityQueue
    import scala.collection.mutable.ArrayBuffer
    import util.control.Breaks._
    var in=io.Source.stdin.getLines()
    val t=in.next().split(" ")

    val n=t(0).toInt

    val m=t(1).toInt
    val edge={for(_<-1 to m) yield Edge(in.next())}.toArray

    var edgeof =Array.fill(n+1)(new ArrayBuffer[(Int,Int,Int)]())
    for(i<-0 until edge.length){
      edgeof(edge(i).u)+=((edge(i).v,i,edge(i).w));
      edgeof(edge(i).v)+=((edge(i).u,i,edge(i).w));
    }
    val d=Array.fill(n+1)(Int.MaxValue)
    val u0=in.next().toInt
    val q = new PriorityQueue[(Int,Int)]()(Ordering.by((t:(Int,Int))=> t._1))
    val selectedEdge=Array.fill(n+1)(-1)

    d(u0)=0
    q.enqueue((d(u0),u0))
    val mark=Array.fill(n+1)(false)
    while(!q.isEmpty){
      breakable{
        val u=q.dequeue._2
        if(mark(u)){
          break
        }
        mark(u)=true
        for(p<-edgeof(u)){
          if(d(p._1)>d(u)+p._3){
            d(p._1)=d(u)+p._3
            q.enqueue((d(p._1),p._1))
            selectedEdge(p._1)=p._2
          }
        }
      }
    }
    for(i<-0 until edge.length){
      val e=edge(i)
      if(d(e.u)==d(e.v)+e.w && edge(selectedEdge(e.u)).w>e.w){
        selectedEdge(e.u)=i

      }
      if(d(e.v)==d(e.u)+e.w && edge(selectedEdge(e.v)).w>e.w){
        selectedEdge(e.v)=i

      }

    }
    var sum=0

    for(i<-1 to n if i != u0){ sum+=edge(selectedEdge(i)).w}
    println(sum)
    for(i<-1 to n if i != u0){ print(selectedEdge(i)+1);print (' ')}
  }
}

object E3{
  def main(args: Array[String]){
   import scala.collection.mutable.PriorityQueue
    import scala.collection.mutable.ArrayBuffer
    import util.control.Breaks._
//    var in=io.Source.stdin.getLines()
    import java.io.{PrintWriter}
    import java.util.{Locale, Scanner}

    val in = new Scanner(System.in)
    val out = new PrintWriter(System.out)

    def nextInt = in.nextInt
    def nextLong = in.nextLong
    def nextDouble = in.nextDouble
    def nextString = in.next

    val n=nextInt

    val m=nextInt
    val U=new Array[Int](m)
    val V=new Array[Int](m)
    val W=new Array[Long](m)
    for(i <- 0 until m)
    {
      U(i)=nextInt
      V(i)=nextInt
      W(i)=nextLong
    }

    var edgeof =Array.fill(n+1)(new ArrayBuffer[(Int,Long)]())
    for(i<-0 until U.length){
      edgeof(U(i))+=((V(i),W(i)));
      edgeof(V(i))+=((U(i),W(i)));
    }
    val d=Array.fill(n+1)(Long.MaxValue)
    val u0=nextInt
    val q = new PriorityQueue[(Long,Int)]()(Ordering.by((t:(Long,Int))=> -t._1))

    d(u0)=0
    q.enqueue((d(u0),u0))
    val mark=Array.fill(n+1)(false)
    while(!q.isEmpty){
      breakable{
        val u=q.dequeue._2
        if(mark(u)){
          break
        }
        mark(u)=true
        for(p<-edgeof(u)){
          if(d(p._1)>d(u)+p._2){
            d(p._1)=d(u)+p._2
            q.enqueue((d(p._1),p._1))
          }
        }
      }
    }

    var sum=0L
    val selectedEdge=Array.fill(n+1)(-1)
    for(i<-0 until U.length){
      if(d(U(i))==d(V(i))+W(i) && (selectedEdge(U(i))== -1 || (W(selectedEdge(U(i)))>W(i)))){
        selectedEdge(U(i))=i

      }
      if(d(V(i))==d(U(i))+W(i) && (selectedEdge(V(i))== -1 || (W(selectedEdge(V(i))))>W(i))){
        selectedEdge(V(i))=i

      }

    }

    for(i<-1 to n if i != u0){ sum+=W(selectedEdge(i))}
    out.println(sum)
    for(i<-1 to n if i != u0){ print((selectedEdge(i)+1)+" ") }
    out.println()
    out.flush
    out.close

  }
}

object E3{
  def main(args: Array[String]){
   import scala.collection.mutable.PriorityQueue
    import scala.collection.mutable.ArrayBuffer
    import util.control.Breaks._
//    var in=io.Source.stdin.getLines()
    import java.io.{PrintWriter}
    import java.util.{Locale, Scanner}

    val in = new Scanner(System.in)
    val out = new PrintWriter(System.out)

    def nextInt = in.nextInt
    def nextLong = in.nextLong
    def nextDouble = in.nextDouble
    def nextString = in.next

    val n=nextInt

    val m=nextInt
    val U=new Array[Int](m)
    val V=new Array[Int](m)
    val W=new Array[Long](m)
    for(i <- 0 until m)
    {
      U(i)=nextInt
      V(i)=nextInt
      W(i)=nextLong
    }

    var edgeof =Array.fill(n+1)(new ArrayBuffer[(Int,Long)]())
    for(i<-0 until U.length){
      edgeof(U(i))+=((V(i),W(i)));
      edgeof(V(i))+=((U(i),W(i)));
    }
    val d=Array.fill(n+1)(Long.MaxValue)
    val u0=nextInt
    val q = new PriorityQueue[(Long,Int)]()(Ordering.by((t:(Long,Int))=> -t._1))

    d(u0)=0
    q.enqueue((d(u0),u0))
    val mark=Array.fill(n+1)(false)
    while(!q.isEmpty){
      breakable{
        val u=q.dequeue._2
        if(mark(u)){
          break
        }
        mark(u)=true
        for(p<-edgeof(u)){
          if(d(p._1)>d(u)+p._2){
            d(p._1)=d(u)+p._2
            q.enqueue((d(p._1),p._1))
          }
        }
      }
    }

    var sum=0L
    val selectedEdge=Array.fill(n+1)(-1)
    for(i<-0 until U.length){
      if(d(U(i))==d(V(i))+W(i) && (selectedEdge(U(i))== -1 || (W(selectedEdge(U(i)))>W(i)))){
        selectedEdge(U(i))=i

      }
      if(d(V(i))==d(U(i))+W(i) && (selectedEdge(V(i))== -1 || (W(selectedEdge(V(i))))>W(i))){
        selectedEdge(V(i))=i

      }

    }

    for(i<-1 to n if i != u0){ sum+=W(selectedEdge(i))}
    out.println(sum)
    for(i<-1 to n if i != u0){ out.print((selectedEdge(i)+1)+' ')}
    out.println()

  }
}


object A1139 {
  def main(args: Array[String]): Unit = {
    val stdin = scala.io.StdIn
    val n = stdin.readInt()
    val str = stdin.readLine()
    var ans = 0L
    for (i <- 0 until n){
      val temp = str(i) - '0'
      if (temp % 2 == 0){
        ans = ans + (i+1)
      }
    }
    println(ans)
  }
}

//package codeforces.contest1139

object EvenSubstrings {

  def main(args: Array[String]): Unit = {
    val n = io.StdIn.readInt()
    val string = io.StdIn.readLine()

    println(string.map(_ - '0').zipWithIndex.filter(_._1 % 2 == 0).map(_._2 + 1).sum)
  }

}

object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer
  import java.util.Arrays

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N = ni()
    val S = ns(N)
    var ans = 0L
    REP(N) { i =>
      if ((S(i) - '0') % 2 == 0) ans += i + 1
    }
    out.println(ans)
  }

  private val oj = System.getenv("ATCODER_DEBUG") == null

  def DEBUG(f: => Unit): Unit = {
    if (!oj){ f }
  }

  def debug(as: Array[Boolean]): Unit = DEBUG {
    debug(as.map(x => if(x) "1" else "0").mkString)
  }

  def debug(as: Array[Int]): Unit = DEBUG {
    debug(as.mkString(" "))
  }

  def debug(as: Array[Long]): Unit = DEBUG {
    debug(as.mkString(" "))
  }

  def debug(s: => String): Unit = DEBUG {
    System.err.println(s)
  }

  def debugL(num: => Long): Unit = DEBUG {
    System.err.println(num)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }
  def TO(from: Int, to: Int)(f: Int => Unit): Unit = {
    REP(to - from + 1, from) { i =>
      f(i)
    }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

import scala.io.StdIn

object A1139 {
  def main(args: Array[String]): Unit = {
    StdIn.readLine
    println(StdIn.readLine.zipWithIndex.withFilter{i=>"2468".contains(i._1)}.map{_._2 + 1}.sum)
  }
}

object A1139 {
  def main(args: Array[String]): Unit = {
    val stdin = scala.io.StdIn
    val n = stdin.readInt()
    val str = stdin.readLine().map(x => x -'0').map(_ & 1)
    var ans = 0L
    for (i <- 0 until n if str(i) == 0){
        ans = ans + (i+1)
    }
    println(ans)
  }
}

object _1139A extends CodeForcesApp {
  import annotation._, collection.{mutable, Searching}, util._, control._, math.Ordering.Implicits._, Searching._, Math._

  override def apply(io: IO): io.type = {
    val _, s = io.read[String]

    val ans = s.toCharArray
      .map(_ - '0')
      .zipWithIndex
      .collect({case (c, i) if c%2 == 0 => i + 1 })
      .sum

    io.write(ans)
  }
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)
  def apply(io: IO): io.type
  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()
}
/***********************************[Scala I/O]*********************************************/
import java.io._, java.util.StringTokenizer
import scala.collection.generic.CanBuild

class IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {
  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))
  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))

  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered
  val printer = new PrintWriter(out, true)

  @inline private[this] def tokenizer() = {
    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()
    tokenizers.headOption
  }

  def read[A](implicit read: IO.Read[A]): A = read.apply(this)
  def read[C[_], A: IO.Read](n: Int)(implicit b: CanBuild[A, C[A]]): C[A] = Iterator.fill(n)(read).to[C]

  def readTill(delim: String): String = tokenizer().get.nextToken(delim)
  def readTillEndOfLine(): String = readTill("\n\r")

  def readAll[A: IO.Read]: (Int, Vector[A]) = {
    val data = read[Vector[A]]
    (data.length, data)
  }

  override def next() = tokenizer().get.nextToken()
  override def hasNext = tokenizer().nonEmpty

  def write(obj: Any): this.type = {
    printer.print(obj)
    this
  }
  def writeLine(): this.type = {
    printer.println()
    this
  }
  def writeLine(obj: Any): this.type = {
    printer.println(obj)
    this
  }
  def writeLines(obj: Traversable[Any]): this.type = writeAll(obj, separator = "\n")
  def writeAll(obj: Traversable[Any], separator: String = " "): this.type = write(obj mkString separator)
  def query[A: IO.Read](question: Any): A = writeLine(question).read

  override def flush() = printer.flush()
  def close() = {
    flush()
    in.close()
    printer.close()
  }
}
object IO {
  class Read[A](val apply: IO => A) {
    def map[B](f: A => B): Read[B] = new Read(apply andThen f)
  }

  object Read {
    implicit def collection[C[_], A: Read](implicit b: CanBuild[A, C[A]]) : Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))
    implicit val string                                                   : Read[String]       = new Read(_.next())
    implicit val int                                                      : Read[Int]          = string.map(_.toInt)
    implicit val long                                                     : Read[Long]         = string.map(_.toLong)
    implicit val bigInt                                                   : Read[BigInt]       = string.map(BigInt(_))
    implicit val double                                                   : Read[Double]       = string.map(_.toDouble)
    implicit val bigDecimal                                               : Read[BigDecimal]   = string.map(BigDecimal(_))
    implicit def tuple2[A: Read, B: Read]                                 : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))
    implicit def tuple3[A: Read, B: Read, C: Read]                        : Read[(A, B, C)]    = new Read(r => (r.read[A], r.read[B], r.read[C]))
    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]               : Read[(A, B, C, D)] = new Read(r => (r.read[A], r.read[B], r.read[C], r.read[D]))
    implicit val boolean                                                  : Read[Boolean]      = string map {s =>
      s.toLowerCase match {
        case "yes" | "true" | "1" => true
        case "no" | "false" | "0" => false
        case _ => s.toBoolean
      }
    }
  }
}


object B extends App {

  def hemoseShopping(an: IndexedSeq[Int], x: Int): Boolean = {
    val n      = an.length
    val (i, j) = (n - x, x - 1)

    val am = an.slice(i, j + 1)

    am.isEmpty || {
      val as       = (an.slice(0, i) ++ an.slice(j + 1, n)).sorted
      val (al, ar) = (as.slice(0, i), as.slice(i, n))

      an.sorted sameElements (al ++ am ++ ar)
    }

  }

  import InOut._

  val t = nextInt()

  (0 until t).foreach { _ =>
    val n  = nextInt()
    val x  = nextInt()
    val an = nextInts(n)

    hemoseShopping(an, x) match {
      case true  => out.println("YES")
      case false => out.println("NO")
    }
  }

  out.flush()

  final object InOut {
    val in  = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))
    val out = new java.io.PrintWriter(System.out, false)

    def nextInt()        = Integer.parseInt(nextToken())
    def nextInts(n: Int) = Array.fill(n)(nextInt())

    def nextLong()        = java.lang.Long.parseLong(nextToken())
    def nextLongs(n: Int) = Array.fill(n)(nextLong())

    def nextBig()        = BigInt(nextToken())
    def nextBigs(n: Int) = Array.fill(n)(nextBig())

    def nextLine() = in.readLine()

    private[this] var tokenizer: java.util.StringTokenizer = _

    def nextToken(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens())
        tokenizer = new java.util.StringTokenizer(in.readLine())
      tokenizer.nextToken()
    }
  }

}

object B extends App {

  def hemoseShopping(an: IndexedSeq[Int], x: Int): Boolean = {
    val bn = an.sorted

    ((an.length - x) until x).forall(i => an(i) == bn(i))
  }

  import InOut._

  val t = nextInt()

  (0 until t).foreach { _ =>
    val n  = nextInt()
    val x  = nextInt()
    val an = nextInts(n)

    hemoseShopping(an, x) match {
      case true  => out.println("YES")
      case false => out.println("NO")
    }
  }

  out.flush()

  final object InOut {
    val in  = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))
    val out = new java.io.PrintWriter(System.out, false)

    def nextInt()        = Integer.parseInt(nextToken())
    def nextInts(n: Int) = Array.fill(n)(nextInt())

    def nextLong()        = java.lang.Long.parseLong(nextToken())
    def nextLongs(n: Int) = Array.fill(n)(nextLong())

    def nextBig()        = BigInt(nextToken())
    def nextBigs(n: Int) = Array.fill(n)(nextBig())

    def nextLine() = in.readLine()

    private[this] var tokenizer: java.util.StringTokenizer = _

    def nextToken(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens())
        tokenizer = new java.util.StringTokenizer(in.readLine())
      tokenizer.nextToken()
    }
  }

}

import java.io._
import java.util.StringTokenizer
import scala.collection.mutable
import scala.collection.mutable._
import scala.collection.immutable._
import scala.util.Sorting.quickSort
import scala.math._

object sample extends App {
    val writer =  new PrintWriter(System.out, false)
    val reader = new BufferedReader(new InputStreamReader(System.in))
    var st = new StringTokenizer("")
    def next(): String = {while (!st.hasMoreTokens) {st = new StringTokenizer(reader.readLine())};st.nextToken()}
    def readInt(): Int = next().toInt
    def readLong(): Long = next().toLong
    def readString(): String = next()

    case class myType(var social: Int, var cp:  Int, var ind: Int)extends Ordered[myType] {
        override def compare(that: myType): Int = {
            if (social < that.social)
                return -1
            else if (social == that.social)
                return 0
            else
                return 1
        }
    }

    val t = readInt()
    for (tt <- 1 to t) {
        val n = readInt()
        val k = readInt()
        var cnt = max(0, min(k, n) - max(n-k+1, 1) + 1)
        val arr = new Array[Int](n - cnt)
        var mx = 0
        var mn = (1e9+1).toInt
        cnt = 0
        var tmp = 0
        var flag = true
        for (i <- 1 to n) {
            tmp = readInt()
            if (i >= max(n-k+1, 1) && i <= min(k, n)) {
                if(mx > tmp)
                    flag = false
                mx = max(mx, tmp)
                mn = min(mn, tmp)
            } else {
                arr(cnt) = tmp
                cnt += 1
            }
        }
        quickSort(arr)
        if (arr.length > 0) {
            if (arr(arr.length/2-1) > mn)
                flag = false
            if (arr(arr.length/2) < mx)
                flag = false
        }
        if (flag) {
            writer.println("YES")
        } else {
            writer.println("NO")
        }
    }
    writer.flush()
}

object B extends App {

  def hemoseShopping(an: IndexedSeq[Int], x: Int): Boolean = {
    val as = an.slice(an.length - x, x)
    as.indices.drop(1).forall(i => as(i - 1) <= as(i))
  }

  import InOut._

  val t = nextInt()

  (0 until t).foreach { _ =>
    val n  = nextInt()
    val x  = nextInt()
    val an = nextInts(n)

    hemoseShopping(an, x) match {
      case true  => out.println("YES")
      case false => out.println("NO")
    }
  }

  out.flush()

  final object InOut {
    val in  = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))
    val out = new java.io.PrintWriter(System.out, false)

    def nextInt()        = Integer.parseInt(nextToken())
    def nextInts(n: Int) = Array.fill(n)(nextInt())

    def nextLong()        = java.lang.Long.parseLong(nextToken())
    def nextLongs(n: Int) = Array.fill(n)(nextLong())

    def nextBig()        = BigInt(nextToken())
    def nextBigs(n: Int) = Array.fill(n)(nextBig())

    def nextLine() = in.readLine()

    private[this] var tokenizer: java.util.StringTokenizer = _

    def nextToken(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens())
        tokenizer = new java.util.StringTokenizer(in.readLine())
      tokenizer.nextToken()
    }
  }

}

import java.io._
import java.util.StringTokenizer
import scala.collection.mutable
import scala.collection.mutable._
import scala.collection.immutable._
import scala.util.Sorting.quickSort
import scala.math._

object sample extends App {
    val writer =  new PrintWriter(System.out, false)
    val reader = new BufferedReader(new InputStreamReader(System.in))
    var st = new StringTokenizer("")
    def next(): String = {while (!st.hasMoreTokens) {st = new StringTokenizer(reader.readLine())};st.nextToken()}
    def readInt(): Int = next().toInt
    def readLong(): Long = next().toLong
    def readString(): String = next()

    case class myType(var social: Int, var cp:  Int, var ind: Int)extends Ordered[myType] {
        override def compare(that: myType): Int = {
            if (social < that.social)
                return -1
            else if (social == that.social)
                return 0
            else
                return 1
        }
    }

    val t = readInt()
    for (tt <- 1 to t) {
        val n = readInt()
        val k = readInt()
        val arr = new Array[Int](n + 1)
        for (i <- 1 to n)
            arr(i) = readInt()
        var mx = 0
        var flag = true
        for (i <- max(n-k+1, 1) to min(k, n)) {
            if (mx > arr(i))
                flag = false
            mx = max(mx, arr(i))
        }
        if (flag) {
            writer.println("YES")
        } else {
            writer.println("NO")
        }
    }
    writer.flush()
}


/**
 * infm, 4/24/14.
 * enjoy ;)
 */
object A {
  val in = {
    val lines = {
      scala.io.Source.stdin.getLines.buffered
      //val bf = new BufferedReader(new InputStreamReader(System.in))
      //Iterator.continually(readLine)
      //Iterator.continually(bf.readLine)
    }
    lines map (_ split ' ') filter (_.nonEmpty) flatten
  }

  //val out = new PrintWriter(System.out)

  def nextInt = in.next().toInt

  def nextLong = in.next().toLong

  def main(args: Array[String]) {
    val n = nextInt
    val k = nextInt
    val s = in.next
    var i = k
    if (k > n - k){
      while (i < n){
        println("RIGHT")
        i += 1
      }
      i -= 1
      while (i >= 0){
        println("PRINT " + s.charAt(i))
        if (i > 0)
          println("LEFT")
        i -= 1
      }
    } else {
      i -= 1
      while (i > 0){
        println("LEFT")
        i -= 1
      }
      while (i < n){
        println("PRINT " + s.charAt(i))
        if (i < n - 1)
          println("RIGHT")
        i += 1
      }
    }
  }
}

/**
 * I've tried to make this piece of code as readable as possible.
 * Enjoy hacking it!
 */
import scala.collection._

object A extends App {

  def tokenizeLine = new java.util.StringTokenizer(readLine)
  def readInts(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toInt) }
  def readLongs(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toLong) }
  def readBigs(n: Int) = { val t = tokenizeLine; Array.fill(n)(BigInt(t.nextToken)) }

  val Array(n, k) = readInts(2)
  val s = readLine

  val dir0 = if (k < (n - k + 1)) -1 else 1
  var i = k

  println(s"PRINT ${s(i - 1)}")

  while (i + dir0 > 0 && i + dir0 <= n) {
    println(if (dir0 < 0) "LEFT" else "RIGHT")
    i += dir0
    println(s"PRINT ${s(i - 1)}")
  }

  //if (k == 1 || k == n) exit

  val dir1 = -dir0
  //if (i != k) i += dir1

  while (i != k) {
    println(if (dir1 < 0) "LEFT" else "RIGHT")
    i += dir1
  }

  while (i + dir1 > 0 && i + dir1 <= n) {
    println(if (dir1 < 0) "LEFT" else "RIGHT")
    i += dir1
    println(s"PRINT ${s(i - 1)}")
  }

}


object B extends App {
  val n = scala.io.StdIn.readInt()

  (0 until n).foreach { _ =>
    val t = scala.io.StdIn.readLine()

    val n0 = t.count(_ == '0')

    val s =
      if (t.length < 3 || n0 == 0 || n0 == t.length) t
      else
        t.tail
          .foldLeft(List(t.head)) { (s, c) =>
            if (s.head != c) c :: s
            else c :: (if (c == '0') '1' else '0') :: s
          }
          .reverse
          .mkString("")

    println(s)
  }
}

object B {
  import InOut._
  def main(args: Array[String]): Unit = {}

  for (_ <- 1 to nextInt) {
    val s = nextLine
    val res = if (s.forall(_ == s.head)) s
    else "01" * s.length

    out.println(res)
  }

  out.flush()

  final object InOut {
    val in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))
    val out = new java.io.PrintWriter(System.out, false)
    private[this] var tokenizer: java.util.StringTokenizer = _
    def nextToken: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new java.util.StringTokenizer(in.readLine)
      tokenizer.nextToken
    }
    def nextInt = Integer.parseInt(nextToken)
    def nextLong = java.lang.Long.parseLong(nextToken)
    def nextBig = BigInt(nextToken)
    def nextInts(n: Int) = Array.fill(n) { nextInt }
    def nextLongs(n: Int) = Array.fill(n) { nextLong }
    def nextBigs(n: Int) = Array.fill(n) { nextBig }
    def nextLine = in.readLine
  }
}

object B extends App {
  val n = scala.io.StdIn.readInt()

  (0 until n).foreach { _ =>
    val t = scala.io.StdIn.readLine()

    val s =
      if (t.forall(_ == t.head)) t
      else "01" * t.length

    println(s)
  }
}