object Main {
  def genRow(rowMax: Int, centerMax: Int) = {
    (0 until (centerMax - rowMax)).map(_ => " ") ++ rowData(rowMax)
  }

  def rowData(rowMax: Int) = {
    ((0 until rowMax) ++ (rowMax to 0 by -1)).map(_.toString)
  }

  def main(args: Array[String]) {
    val num = readInt()
    for (i <- (0 until num) ++ (num to 0 by -1)) {
      println(genRow(i, num).mkString(" "))
    }
  }
}

import scala.collection.mutable.Queue
object Main {

  def main(args: Array[String]): Unit = {
    val n = readInt()
    val arr = (0 until 2*n+1).foldLeft(List[Array[Char]]())((l,i)=>(" "*(2*n+1-Math.abs(i-n))).toCharArray()+:l).toArray
    val que= Queue((n,n,n))
    while(!que.isEmpty){
      val (x,y,v) = que.dequeue
      if(v>=0 && arr(y)(x)==' '){
        arr(y)(x) = (""+v)(0)
        List((0,1),(1,0),(0,-1),(-1,0)).map(dir=>que.enqueue((x+dir._1,y+dir._2,v-1)))
      }
    }
    arr.map(x=>println(x.mkString(" ")))
  }

}

import java.util.StringTokenizer

object _118B extends App {
  var token = new StringTokenizer("")
  def next = {
    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)
    token.nextToken()
  }
  val n = next.toInt + 1
  for (i <- 0 until n) {
    print((1 to 2 * (n - 1 - i)).map(i => ' ').mkString)
    for (j <- 0 to i) print(j + (if (j < i) " " else ""))
    for (j <- (i - 1).to(0, -1)) print(" " + j)
    println
  }
  for (i <- (n - 2).to(0, -1)) {
    print((1 to 2 * (n - 1 - i)).map(i => ' ').mkString)
    for (j <- 0 to i) print(j + (if (j < i) " " else ""))
    for (j <- (i - 1).to(0, -1)) print(" " + j)
    println
  }
}

object B118 {
  @inline def read = scala.io.StdIn.readLine

  @inline def tokenizeLine = new java.util.StringTokenizer(read)

  def readInts(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)
  }

  def readLongs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)
  }

  def readBigs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))
  }

  def main(args: Array[String]): Unit = {
    val Array(n) = readInts(1)
    val res = Array.fill(n+1)(Array.fill[Char](2*n+1)(' '))
    for(i <- 0 until n+1; j <- 0 until 2*n+1) {
      if(i + j >= n && j <= n) {
        res(i)(j) = ('0' + (i+j) - n).toChar
      } else if (j > n && j <= i+n) {
        res(i)(j) = ('0' + i+n - j).toChar
      }
    }

    println(res.map(_.mkString(" ")).map(_.replaceAll("""(?m)\s+$""", "")).mkString("\n"))
    println(res.dropRight(1).reverse.map(_.mkString(" ")).map(_.replaceAll("""(?m)\s+$""", "")).mkString("\n"))
  }
}

import java.util.Scanner

object B extends App {
	val n = new Scanner(System.in).nextInt()
	for (i <- 0 until 2 * n + 1) {
		val line = new StringBuffer()
		val numberOfSpaces = (n - i).abs
		val max = (2 * n - i) min i
		for (_ <- 1 to numberOfSpaces) line.append("  ")
		for (j <- 0 to max) {
			line.append(j)
			line.append(' ')
		}
		for (j <- max - 1 to 0 by -1) {
			line.append(j)
			line.append(' ')
		}
		line.deleteCharAt(line.length() - 1)
		println(line.toString)
	}
}

import java.util.Scanner
import java.io.PrintWriter
import scala.annotation.tailrec
import scala.collection.mutable
import scala.util.Random

object P118B extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  val N = sc.nextInt

  def line(i: Int): String = {
    " " * 2 * (N - i) + ((0 until i) ++ List.range(i, -1, -1)).mkString(" ")
  }

  for (i <- (0 until N) ++ List.range(N, -1, -1))
    out.println(line(i))
  out.close
}

import java.util.StringTokenizer

object _118B extends App {
  var token = new StringTokenizer("")
  def next = {
    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)
    token.nextToken()
  }
  val n = next.toInt
  for (i <- 0 until n) {
    print((1 to 2 * (n - 1 - i)).map(i => ' ').mkString)
    for (j <- 0 to i) print(j + " ")
    for (j <- (i - 1).to(0, -1)) print(j + (if (j > 0) " " else ""))
    println
  }
  for (i <- (n - 2).to(0, -1)) {
    print((1 to 2 * (n - 1 - i)).map(i => ' ').mkString)
    for (j <- 0 to i) print(j + " ")
    for (j <- (i - 1).to(0, -1)) print(j + (if (j > 0) " " else ""))
    println
  }
}

import java.util.StringTokenizer

object _118B extends App {
  var token = new StringTokenizer("")
  def next = {
    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)
    token.nextToken()
  }
  val n = next.toInt + 1
  for (i <- 0 until n) {
    print((1 to 2 * (n - 1 - i)).map(i => ' ').mkString)
    for (j <- 0 to i) print(j + " ")
    for (j <- (i - 1).to(0, -1)) print(j + (if (j > 0) " " else ""))
    println
  }
  for (i <- (n - 2).to(0, -1)) {
    print((1 to 2 * (n - 1 - i)).map(i => ' ').mkString)
    for (j <- 0 to i) print(j + " ")
    for (j <- (i - 1).to(0, -1)) print(j + (if (j > 0) " " else ""))
    println
  }
}

import java.util.Scanner

object B extends App {
	val n = new Scanner(System.in).nextInt()
	for (i <- 0 until 2 * n + 1) {
		val line = new StringBuffer()
		val numberOfSpaces = (n - i).abs
		val max = (2 * n - i) min i
		for (_ <- 1 to numberOfSpaces) line.append(' ')
		for (j <- 0 to max) line.append(j)
		for (j <- max - 1 to 0 by -1) line.append(j)
		println(line.toString)
	}
}

import scala.collection.mutable.Queue
object Main {

  def main(args: Array[String]): Unit = {
    val n = readInt()
    val arr = (0 until 2*n+1).foldLeft(List[Array[Char]]())((l,i)=>(" "*(2*n+1-Math.abs(i-n))).toCharArray()+:l).toArray
    val que= Queue((n,n,n))
    while(!que.isEmpty){
      val (x,y,v) = que.dequeue
      if(v>=0 && arr(y)(x)==' '){
        arr(y)(x) = (""+v)(0)
        List((0,1),(1,0),(0,-1),(-1,0)).map(dir=>que.enqueue((x+dir._1,y+dir._2,v-1)))
      }
    }
    arr.map(x=>println(x.mkString))
  }

}

import scala.collection.mutable.Queue
object Main {

  def main(args: Array[String]): Unit = {
    val n = readInt()
    val arr = (1 to 2*n+1).foldLeft(List[Array[Char]]())((l,_)=>(" "*(2*n+1)).toCharArray()+:l).toArray
    val que= Queue((n,n,n))
    while(!que.isEmpty){
      val (x,y,v) = que.dequeue
      if(v>=0 && arr(y)(x)==' '){
        arr(y)(x) = (""+v)(0)
        List((0,1),(1,0),(0,-1),(-1,0)).map(dir=>que.enqueue((x+dir._1,y+dir._2,v-1)))
      }
    }
    arr.map(x=>println(x.mkString))
  }

}


object CodeforcesRound666a {

  import java.io.{BufferedReader, PrintStream}

  import scala.io.Source

  def main(args: Array[String]): Unit = {
    exec(Source.stdin.bufferedReader, System.out)
  }

  def exec(implicit
           reader: BufferedReader,
           writer: PrintStream): Unit = {
    val t: Int = rl_int
    (1 to t).foreach(_ => test())
  }

  def test()
          (implicit
           reader: BufferedReader,
           writer: PrintStream): Unit = {
    val n = rl_int
    val sa = (1 to n).flatMap(_ => rl)
    val res = sa.groupBy(identity).mapValues(_.size).values.forall(_ % n == 0)
    writer.println(if (res) "YES" else "NO")
  }

  def sqr(a: Long): Long = a * a

  def rl(implicit reader: BufferedReader): String = reader.readLine
  def rll(implicit reader: BufferedReader): Array[String] = reader.readLine.split(' ')

  def rl_bool(implicit reader: BufferedReader): Boolean = rl.toBoolean
  def rl_byte(implicit reader: BufferedReader): Byte = rl.toByte
  def rl_short(implicit reader: BufferedReader): Short = rl.toShort
  def rl_int(implicit reader: BufferedReader): Int = rl.toInt
  def rl_long(implicit reader: BufferedReader): Long = rl.toLong
  def rl_float(implicit reader: BufferedReader): Float = rl.toFloat
  def rl_double(implicit reader: BufferedReader): Double = rl.toDouble

  def rll_bool(implicit reader: BufferedReader): Array[Boolean] = rll.map(_.toBoolean)
  def rll_byte(implicit reader: BufferedReader): Array[Byte] = rll.map(_.toByte)
  def rll_short(implicit reader: BufferedReader): Array[Short] = rll.map(_.toShort)
  def rll_int(implicit reader: BufferedReader): Array[Int] = rll.map(_.toInt)
  def rll_long(implicit reader: BufferedReader): Array[Long] = rll.map(_.toLong)
  def rll_float(implicit reader: BufferedReader): Array[Float] = rll.map(_.toFloat)
  def rll_double(implicit reader: BufferedReader): Array[Double] = rll.map(_.toDouble)

}

import scala.io.StdIn._

object taskA extends App {

  val sets = readInt
  var lst: List[String] = List()

  def check(input: String, len: Int): String = {
    var checked: scala.collection.mutable.Map[Char, Int] = scala.collection.mutable.Map()
    (0 until input.length()).foreach { x =>
      val char = input.charAt(x)
      if (checked.contains(char)) checked(char) += 1
      else checked += (char -> 1)
    }

    if (checked.values.filter(_ % len == 0).size == checked.size) "YES"
    else "NO"
  }

  (1 to sets).foreach { _ =>
    val strs = readInt
    var whole: String = ""
    (1 to strs).foreach(_ => whole += readLine)
    lst = lst ::: List(check(whole, strs))
  }

  lst.foreach { x =>
    println(x)
  }

}

import scala.collection.mutable.ArrayBuffer

object A extends App {
  import java.io._
  import java.nio.file.{Files, Path}
  import java.util.StringTokenizer
  import scala.io.Source
  import scala.io.Codec

  /* Implicit methods */
  implicit def intWithTimes(n: Int) = {
    new {
      def times(f: => Unit): Unit = 1.to(n).foreach { _ => f }
    }
  }
  /* Implicit methods */

  //  val in = new CustomScanner(Source.fromResource("input.txt").mkString)
  val in  = new CustomScanner(System.in)
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val inputLines = in.nextInt()

    inputLines.times {
      val m = in.nextInt()

      var test = ""
      m.times({
        test += in.nextLine()
      })
      val r = test.groupBy(x => x).exists(x => x._2.size % m != 0)
      if (r) println("NO") else println("YES")
    }
  }

  try {
    solve()
  } catch {
    case ex: Exception =>
      println(ex)
      sys.exit(9999)
  } finally {
    out.flush()
    out.close()
  }

  /**
    * Util methods
    */

  def printArr[T](in: Array[T]) = {
    in.foreach(print)
    println()
  }

  /**
    * Scala implementation of a faster java.util.Scanner
    * See: http://codeforces.com/blog/entry/7018
    */
  class CustomScanner(reader: LineNumberReader) extends Iterator[String] with AutoCloseable {

    def this(reader: BufferedReader) = this(new LineNumberReader(reader))

    def this(reader: Reader) = this(new BufferedReader(reader))

    def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))

    def this(path: Path)(implicit codec: Codec) = this(Files.newBufferedReader(path, codec.charSet))

    def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)

    def this(str: String) = this(new StringReader(str))

    private[this] val tokenizers = {
      Iterator
        .continually(reader.readLine())
        .takeWhile(_ != null)
        .map(new StringTokenizer(_))
        .filter(_.hasMoreTokens)
    }

    private[this] var current: Option[StringTokenizer] = None

    @inline private[this] def tokenizer(): Option[StringTokenizer] =
      current.find(_.hasMoreTokens) orElse {
        current = if (tokenizers.hasNext) Some(tokenizers.next()) else None
        current
      }

    /**
      * Unlike Java's scanner which returns till end of current line, this actually returns the next line
      *
      * @see line() if you want the Java behaviour
      */
    def nextLine(): String = {
      current = None // reset
      reader.readLine()
    }

    def lineNumber: Int = reader.getLineNumber

    def line(): String = tokenizer().get.nextToken("\n\r")

    def nextLineInt(n: Int): ArrayBuffer[Int] = {
      var data = ArrayBuffer[Int]()
      n.times({
        data += nextInt()
      })
      data
    }

    def nextString(): String = next()

    def nextChar(): Char = next().ensuring(_.length == 1).head

    def nextBoolean(): Boolean = next().toBoolean

    def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)

    def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)

    def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)

    def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)

    def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)

    def nextFloat(): Float = next().toFloat

    def nextDouble(): Double = next().toDouble

    def nextBigDecimal(): BigDecimal = BigDecimal(next())

    override def next(): String = tokenizer().get.nextToken()

    override def hasNext: Boolean = tokenizer().nonEmpty

    override def close(): Unit = reader.close()
  }
}

import scala.io.StdIn._

object taskA extends App {

  val sets = readInt
  var lst: List[String] = List()

  def check(input: String, len: Int): String = {
    var checked: scala.collection.mutable.Map[Char, Int] = scala.collection.mutable.Map()
    (1 until input.length()).foreach { x =>
      val char = input.charAt(x)
      if (checked.contains(char)) checked(char) += 1
      else checked += (char -> 1)
    }
    if (checked.values.toList.filter(_ % len != 0).isEmpty) "NO"
    else "YES"

  }

  (1 to sets).foreach { _ =>
    val strs = readInt
    var whole: String = ""
    (0 until strs).foreach(_ => whole += readLine)
    lst = lst ::: List(check(whole, strs))
  }

  lst.foreach { x =>
    println(x)
  }

}

import scala.io.StdIn._

object taskA extends App {

  val sets = readInt
  var lst: List[String] = List()

  def check(input: String, len: Int): String = {
    var checked: scala.collection.mutable.Map[Char, Int] = scala.collection.mutable.Map()
    (0 until input.length()).foreach { x =>
      val char = input.charAt(x)
      if (checked.contains(char)) checked(char) += 1
      else checked += (char -> 1)
    }
    println()
    println(checked)
    if (checked.values.filter(_ % len == 0).size == checked.size) "YES"
    else "NO"
  }

  (1 to sets).foreach { _ =>
    val strs = readInt
    var whole: String = ""
    (1 to strs).foreach(_ => whole += readLine)
    lst = lst ::: List(check(whole, strs))
  }

  lst.foreach { x =>
    println(x)
  }

}


object Main {
  import java.io.{BufferedReader, InputStream, InputStreamReader}
  import java.util.StringTokenizer
  import scala.reflect.ClassTag

  def main(args: Array[String]): Unit = {
    val out = new java.io.PrintWriter(System.out)
    new Main(out, new InputReader(System.in)).solve()
    out.flush()
  }

  private val oj = System.getenv("ATCODER_DEBUG") == null
  def DEBUG(f: => Unit): Unit = {
    if (!oj){ f }
  }
  def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) "1" else "0").mkString) }
  def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(" ")) }
  def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(" ")) }
  def debugDim(m: Array[Array[Long]]): Unit = if (!oj){
    REP(m.length) { i =>
      debug(m(i))
    }
  }
  def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){
    REP(m(0).length) { j =>
      REP(m.length) { i =>
        System.err.print(m(i)(j))
        System.err.print(" ")
      }
      System.err.println()
    }
  }
  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 = Integer.parseInt(next())
    def nextLong(): Long = java.lang.Long.parseLong(next())
    def nextChar(): Char = next().charAt(0)

    def ni(): Int = nextInt()
    def nl(): Long = nextLong()
    def nc(): Char = nextChar()
    def ns(): String = 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]): Array[Long] = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

class Main(out: java.io.PrintWriter, sc: Main.InputReader) {
  import sc._
  import Main._
  import java.util.Arrays.sort

  import scala.collection.mutable
  import math.{abs, max, min}
  import mutable.ArrayBuffer

  // toIntとか+7とかするならvalにしろ
  @inline private def MOD = 1000000007

  def solve(): Unit = {
    val N = ni()
    var p = 1
    val A = Array.ofDim[Int](N + 1)
    TO(2, N) { i =>
      if (A(i) == 0) {
        var d = i
        A(d) = p
        while (d + i <= N) {
          d += i
          A(d) = p
        }
        p += 1
      }
    }

    out.println(A.drop(2).mkString(" "))
  }
}

import scala.io.StdIn._

object Main {
  def main(args: Array[String]): Unit = {
    val n = readInt
    var c = 1
    val arr = new Array[Int](n+1)
    for(i <- 2 to n) {
      if (arr(i) == 0) {
        arr(i) = c
        for (j <- i to n by i) {
          arr(j) = c
        }
        c += 1
      }
    }
    println(arr.tail.tail.mkString(" "))
  }
}


import java.io._
import java.util.Locale
import scala.annotation.tailrec

object Easy {
  val reader = new BufferedReader(new InputStreamReader(System.in))
  def readInt = reader.readLine().toInt
  def readInts = reader.readLine().split(" ").map(_.toInt)
  def readLongs = reader.readLine().split(" ").map(_.toLong)

  val n = readInt
  val a = readInts
  val Array(i, j) = readInts
  def ans = a.take(j - 1).sum -a.take(i - 1).sum

  def main(a: Array[String]) {
    println(ans)
  }
}

import scala.io.Source

object a14 {
  def main(args: Array[String]): Unit = {
    val Array(n,ds,Array(a,b)) = Source.stdin.getLines().take(3).map(_.split(' ').map(_.toInt)).toArray
    val dss = ds.scanLeft(0)(_ + _)
    println(dss(b-1) - dss(a-1))
  }

}

import java.util.StringTokenizer

object _38A extends App {
  var token = new StringTokenizer("")
  def next = {
    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)
    token.nextToken()
  }
  val n = next.toInt
  val a = (0 until n - 1).map(i => next.toInt)
  val from = next.toInt - 1
  val to = next.toInt - 1
  println((from until to).map(i => a(i)).sum)
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val n = in.next().toInt
  val d = in.next().split(" ").map(_.toInt)
  val Array(a, b) = in.next().split(" ").map(_.toInt - 1)
  println(d.slice(a, b).sum)
}

object A38 {

  import IO._

  def main(args: Array[String]): Unit = {
    val Array(n) = readInts(1)
    val in = readInts(n-1)
    var Array(a, b) = readInts(2).map(_-1)
    var res = 0
    while(a < b) {
      res += in(a)
      a += 1
    }
    println(res)
  }

  object IO {
    @inline def read: String = scala.io.StdIn.readLine

    @inline def tokenizeLine = new java.util.StringTokenizer(read)

    def readInts(n: Int): Array[Int] = {
      val tl = tokenizeLine;
      Array.fill(n)(tl.nextToken.toInt)
    }

    def readLongs(n: Int): Array[Long] = {
      val tl = tokenizeLine;
      Array.fill(n)(tl.nextToken.toLong)
    }

    def readBigs(n: Int): Array[BigInt] = {
      val tl = tokenizeLine;
      Array.fill(n)(BigInt(tl.nextToken))
    }
  }

}

import java.util.Scanner
import java.io.PrintWriter
import scala.annotation.tailrec
import scala.collection.mutable
import scala.util.Random

object P038A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  val N = sc.nextInt
  val D = List.fill(N - 1)(sc.nextInt)
  val A, B = sc.nextInt

  def solve: Int = ((A - 1) until (B - 1)).map(D(_)).sum

  out.println(solve)
  out.close
}

object CF38A extends App {

    val n = readLine().toInt
    val d = readLine.split(" ").map(_.toInt)
    val range = readLine.split(" ").map(_.toInt)
    val a = range(0)
    val b = range(1)
    println(d.drop(a - 1).take(b - a).sum)

}

object Main {
  def main(args: Array[String]) {
    readLine()
    val ar = readLine().split(" ").map(_.toInt)
    val ab = readLine().split(" ").map(_.toInt)
    val a = ab(0)
    val b = ab(1)
    println(ar.drop(a - 1).take(b - a).sum)
  }
}

object A00038 extends App {
  def parseInt(str: String, count: Int): Seq[Int] = {
    val scanner = new java.util.Scanner(str)
    val res = (1 to count) map (_ => scanner.nextInt())
    scanner.close()
    res
  }
  def scanInts(count: Int): Seq[Int] = parseInt(Console.readLine, count)

  def oneIntLine = {
    val Seq(count) = parseInt(Console.readLine(), 1);
    count
  }

  val ranks = oneIntLine
  val years = scanInts(ranks - 1)
  val Seq(a, b) = scanInts(2)
  println(years.drop(a - 1).take(b - a).sum)
}

object Flask {

  def main(args: Array[String]): Unit = {
    var n = readLine.toInt
    var data = readLine.split(" ").map(_.toInt)
    var input = readLine.split(" ").map(_.toInt)
    var a = input(0) - 1; var b = input(1) - 1

    println(List.range(a, b).foldLeft(0)((res, i) => res + data(i)))
  }
}

object A00038 extends App {
  def parseInt(str: String, count: Int): Seq[Int] = {
    val scanner = new java.util.Scanner(str)
    val res = (1 to count) map (_ => scanner.nextInt())
    scanner.close()
    res
  }
  def scanInts(count: Int): Seq[Int] = parseInt(Console.readLine, count)

  def oneIntLine = {
    val Seq(count) = parseInt(Console.readLine(), 1);
    count
  }

  val ranks = oneIntLine
  val years = scanInts(ranks - 1)
  val Seq(a, b) = scanInts(2)
  println(years.drop(a - 1).take(b - 1).sum)
}


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

  override def apply(io: IO): io.type = {
    val as = 0 +: io.read[IndexedSeq[Int]]

    def isValid(k: Int) = {
      val xs = mutable.Map.empty[Int, Int]
      def update(i: Int, x: Int) = xs.getOrElseUpdate(i, x) == x
      (1 until as.length).forall(i => update((i - 1)%k, as(i) - as(i - 1)))
    }

    val ans = (1 until as.length).filter(isValid)
    io.writeLine(ans.length).writeAll(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 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 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 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 A = na(N)
    val D = Array.ofDim[Int](N)
    D(0) = A(0)
    rep(N - 1, 1) { i =>
      D(i) = A(i) - A(i - 1)
    }

    val ans = ArrayBuffer[Int]()
    rep(N, 1) { k =>
      val ok = 1 to N / k forall { g =>
        val l = g * k
        0 until k forall { i =>
          i + l >= N || D(i) == D(i + l)
        }
      }
      if (ok) ans += k
    }

    out.println(ans.length)
    out.println(ans.mkString(" "))
  }

  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): Array[Int] = map(n)(_ => ni())
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm(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 map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

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

import java.io._
import java.util.StringTokenizer

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

object A extends App {

  def solve(in: InputReader): Unit = {
    val n = in.nextInt
    val arr = Array.fill(n)(in.nextInt)
    var i = 0
    val diff = Array(arr(0)) ++ Array.fill(n - 1) {
      i += 1
      arr(i) - arr(i - 1)
    }

    val ans = ArrayBuffer[Int]()
    (1 until n).foreach { i =>
      var ok = true
      (0 until n).foreach { j =>
        ok &= diff(j) == diff(j % i)
      }
      if (ok)
        ans += i
    }
    ans += n
    println(ans.size)
    println(ans.mkString(" "))
  }

  solve(new InputReader(System.in))

  private class InputReader(val in: InputStream) {

    private val reader: BufferedReader = new BufferedReader(new InputStreamReader(in))
    private var tokenizer: StringTokenizer = _

    def nextInt: Int = {
      next.toInt
    }

    def nextDouble: Double = {
      next.toInt
    }

    def nextLong: Double = {
      next.toInt
    }

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

    def readLine: String = {
      try {
        reader.readLine()
      } catch {
        case e: IOException => throw new RuntimeException(e)
      }
    }
  }

}

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 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 A = na(N)
    val D = Array.ofDim[Int](N)
    D(0) = A(0)
    rep(N - 1, 1) { i =>
      D(i) = A(i) - A(i - 1)
    }

    val ans = ArrayBuffer[Int]()
    rep(N, 1) { k =>
      val ok = 1 to N / k forall { g =>
        val l = g * k
        0 until g forall { i =>
          D(i) == D((i + l) % N)
        }
      }
      if (ok) ans += k
    }

    out.println(ans.length)
    out.println(ans.mkString(" "))
  }

  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): Array[Int] = map(n)(_ => ni())
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm(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 map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

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


import scala.collection.mutable.ListBuffer
import scala.io.StdIn

object PolycarpsPractice {

  def main(args: Array[String]): Unit = {
    val k = StdIn.readLine().split(" ").map(_.toInt).apply(1)
    val ns = StdIn.readLine().split(" ").map(_.toInt)
    val (parts, sum) = solve(ns, k)
    println(sum)
    println(parts.mkString(" "))
  }

  def solve(ns: Seq[Int], k: Int): (Seq[Int], Int) = {
    val bla = biggestElementsIndex(ns, k)
    (step(ListBuffer(), bla.map(_._2 + 1).sorted, 0, ns.length),
     bla.map(_._1).sum)
  }

  def step(solution: ListBuffer[Int],
           biggestIndex: Seq[Int],
           used: Int,
           length: Int): Seq[Int] = {
    if (biggestIndex.size == 1) {
      solution += length - used
    } else {
      val index = biggestIndex.head
      step(solution += (index - used), biggestIndex.tail, index, length)
    }
  }

  def biggestElementsIndex(ns: Seq[Int], k: Int): Seq[(Int, Int)] = {
    ns.zipWithIndex.sorted.reverse.take(k)
  }
}

object CF498B extends App {

  import java.io.PrintWriter
  import java.util.Scanner

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

  def solve = {
    val n = in.nextInt
    val k = in.nextInt

    val problems = (new Array[Int](n)).map(_ => in.nextInt)

    // find the k more difficult problems in original order
    val difficultProblems = problems.zipWithIndex.sortBy(_._1).reverse.take(k).sortBy(_._2)
    // max score
    out.println(difficultProblems.map(_._1).sum)

    val difProbIdx = difficultProblems.map(_._2)

    // difference between indexes
    var result = difProbIdx.zip(-1 +: difProbIdx.dropRight(1)).map(x => x._1 - x._2)
    result(k-1) += n - result.sum // take all the remaining problems

    out.println(result.mkString(" "))
  }

  solve
  out.flush
  out.close
}

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 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, K = ni()
    val A = na(N)
    val B = A.zipWithIndex
    Sorting.quickSort(B)(Ordering.by(_._1))
    val highs = B.takeRight(K).map(_._2)
    Sorting.quickSort(highs)
    val segs = Array.ofDim[Int](K)
    segs(0) = highs(0) + 1
    REP(K - 1, 1) { i =>
      segs(i) = highs(i) - highs(i - 1)
    }
    segs(K - 1) += N - highs(K - 1) - 1

    out.println(highs.map(A).sum)
    out.println(segs.mkString(" "))
  }

  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 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[Int](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

import scala.collection.mutable.ListBuffer
import scala.io.StdIn

object PolycarpsPractice {

  def main(args: Array[String]): Unit = {
    val k = StdIn.readLine().split(" ").map(_.toInt).apply(1)
    val ns = StdIn.readLine().split(" ").map(_.toInt)
    println(solve(ns, k).mkString(" "))
  }

  def solve(ns: Seq[Int], k: Int): Seq[Int] = {
    step(ListBuffer(), biggestElementsIndex(ns, k), 0, ns.length)
  }

  def step(solution: ListBuffer[Int], biggestIndex: Seq[Int], used : Int, length : Int): Seq[Int] = {
    if (biggestIndex.size == 1) {
      solution += length - used
    } else {
      val index = biggestIndex.head
      step(solution += (index - used), biggestIndex.tail, index, length)
    }
  }

  def biggestElementsIndex(ns: Seq[Int], k: Int): Seq[(Int)] = {
    ns.zipWithIndex.sorted.reverse.take(k).map(_._2 + 1).sorted
  }
}

import scala.collection.mutable.ListBuffer
import scala.io.StdIn

object PolycarpsPractice {

  def main(args: Array[String]): Unit = {
    val k = StdIn.readLine().split(" ").map(_.toInt).apply(1)
    val ns = StdIn.readLine().split(" ").map(_.toInt)
    val (parts, sum) = solve(ns, k)
    println(sum)
    println(parts.mkString(" "))
  }

  def solve(ns: Seq[Int], k: Int): (Seq[Int], Int) = {
    val bla = biggestElementsIndex(ns, k)
    (step(ListBuffer(), bla.map(_._2 + 1), 0, ns.length), bla.map(_._1).sum)
  }

  def step(solution: ListBuffer[Int],
           biggestIndex: Seq[Int],
           used: Int,
           length: Int): Seq[Int] = {
    if (biggestIndex.size == 1) {
      solution += length - used
    } else {
      val index = biggestIndex.head
      step(solution += (index - used), biggestIndex.tail, index, length)
    }
  }

  def biggestElementsIndex(ns: Seq[Int], k: Int): Seq[(Int, Int)] = {
    ns.zipWithIndex.sorted.reverse.take(k).sorted
  }
}

import scala.collection.mutable.ListBuffer

object PolycarpsPractice {

  def main(args: Array[String]): Unit = {
    println(solve(Seq(5, 1, 4, 3, 2), 3).mkString(" "))
    println(solve(Seq(5, 4, 2, 6, 5, 1, 9, 2), 3).mkString(" "))
    println(solve(Seq(1, 1, 1, 1, 1), 1).mkString(" "))
    println(solve(Seq(1, 2000, 2000, 2), 2).mkString(" "))
  }

  def solve(ns: Seq[Int], k: Int): Seq[Int] = {
    step(ListBuffer(), biggestElementsIndex(ns, k), 0, ns.length)
  }

  def step(solution: ListBuffer[Int], biggestIndex: Seq[Int], used : Int, length : Int): Seq[Int] = {
    if (biggestIndex.size == 1) {
      solution += length - used
    } else {
      val index = biggestIndex.head
      step(solution += (index - used), biggestIndex.tail, index, length)
    }
  }

  def biggestElementsIndex(ns: Seq[Int], k: Int): Seq[(Int)] = {
    ns.zipWithIndex.sorted.reverse.take(k).map(_._2 + 1).sorted
  }
}