Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.The decreasing coefficient of permutation p1, p2, ..., pn is the number of such i (1 ≤ i < n), that pi > pi + 1.You have numbers n and k. Your task is to print the permutation of length n with decreasing coefficient k.

The single line contains two space-separated integers: n, k (1 ≤ n ≤ 105, 0 ≤ k < n) — the permutation length and the decreasing coefficient.

In a single line print n space-separated integers: p1, p2, ..., pn — the permutation of length n with decreasing coefficient k.  If there are several permutations that meet this condition, print any of them. It is guaranteed that the permutation with the sought parameters exists.

object CF285A {
    def main(argv: Array[String]) {
        val in = new java.util.Scanner(System.in)
        val out = new java.io.PrintWriter(System.out)
        val n = in.nextInt
        val k = in.nextInt
        val d = n - k - 1
        val ans = (1 to d) ++ (n until d by -1)
        out.println(ans.mkString(" "))
        out.close
    }
}

import java.util.StringTokenizer

object _285A extends App {
  var token = new StringTokenizer("")
  def next = {
    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)
    token.nextToken()
  }
  val n = next.toInt
  val k = next.toInt
  val a = (1 to n).toArray

  def reverse(l: Int, r: Int): Unit = {
    if (l < r) {
      val cb = a(l)
      a(l) = a(r)
      a(r) = cb
      reverse(l + 1, r - 1)
    }
  }

  reverse(0, k)
  println(a.mkString(" "))
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, k) = in.next().split(" ").map(_.toInt)
  val r = (n to n - k + 1 by -1).toList ::: (1 until (n - k + 1)).toList
  println(r.mkString(" "))
}

import scala.io._
import java.util.StringTokenizer
import java.io.BufferedReader

object Main {

    def main(args: Array[String]): Unit = {
        val N = nextInt
        val K = nextInt
        (K+1) to 1 by -1 foreach println
        (K+2) to N foreach println
    }

    class Tokenizer(in: BufferedReader, splitOn: String = " \n\t\r\f")
    {
        private var tokenizer = new StringTokenizer("")
        def readLine() = in.readLine()
        def nextToken(): String = {
            while (!tokenizer.hasMoreTokens) {
                val line = readLine
                if (line == null) return null
                tokenizer = new StringTokenizer(line, splitOn)
            }
            tokenizer.nextToken
        }
        def next[A](f: String => A) = f(nextToken)
        def nextSeq[A](f: () => A, count: Int) = (for (i <- 0 until count) yield f())
    }

    implicit val tokenizer = new Tokenizer(Console.in)

    def nextInt()(implicit t: Tokenizer) = t.next(_.toInt)
    def nextLong()(implicit t: Tokenizer) = t.next(_.toLong)
    def nextDouble()(implicit t: Tokenizer) = t.next(_.toDouble)
    def nextBigInt()(implicit t: Tokenizer) = t.next(BigInt(_))
    def nextSeq[A](f: () => A, count: Int = nextInt())(implicit t: Tokenizer) =
        (for (i <- 0 until count) yield f())
}

object A285 {

  import IO._
  import collection.{mutable => cu}

  def main(args: Array[String]): Unit = {
    val Array(n, k) = readInts(2)
    val in = (1 to n).toArray
    val res = in.takeRight(k).reverse ++ in.take(n-k)
    println(res.mkString(" "))
  }

  object IO {
    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))

    //    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream("src/input")))
    @inline def read: String = input.readLine()

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

    def readInt: Int = tokenizeLine.nextToken.toInt

    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))
    }
  }

}

object CF285A extends App {
  val in = new java.util.Scanner(System.in)
  val out = new java.io.PrintWriter(System.out)

  val n = in.nextInt
  val k = in.nextInt
  val e = n-k;
  val sol = (n until e by -1) ++ (1 to e)
  out.println(sol.mkString(" "))

  out.close
}

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

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

  val N, K = sc.nextInt

  val answer = {
    List.range(N, N - K, -1) ++ List.range(1, N - K + 1)
  }.mkString(" ")

  out.println(answer)
  out.close
}

object SlightlyDecreasingPermutations extends App {
	var n: Int = 0;
	var k: Int = 0;
	val inputPattern = "(\\d+) (\\d+)".r;
	val inputPattern(tmpN,tmpK) = readLine;
	n = tmpN.toInt;
	k = tmpK.toInt;

//  StringBuilder sb = new StringBuilder(n*2);
	var s: StringBuilder = new StringBuilder();
	for (i <- n until n-k by -1) {
	  s.append(i+" ");
	}

	for (i <- 1 to n-k) {
	  s.append(i+" ");
	}

	println(s.substring(0, s.length()-1));
}

import annotation.tailrec
import java.io._

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

  val Array(n, k) = readInts
  def ans = ((n to (n - k + 1)).by(-1) ++ (1 to n - k)).mkString(" ")

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

object Main {
  def main(args: Array[String]) {
    val nm = readLine().split(" ").map(_.toInt)
    val n = nm(0)
    val m = nm(1)
    val a = (1 to n)
    val (head, tail) = a.splitAt(n - m - 1)
    println((head ++ tail.reverse).mkString(" "))
  }
}

import java.util.Scanner

object Main {

  def main(args: Array[String]): Unit = {
     var scan = new Scanner(System.in)
     val n = scan.nextInt()
     val k = scan.nextInt()
     val p = List.range(1, n + 1)
     val sorted = p.sorted(Ordering[Int].reverse)
     val (first, second) = sorted.splitAt(n - k - 1)
     val ans = second ::: first.sorted(Ordering[Int])
     val sb = new StringBuilder()
     ans.foreach(x => sb.append(x + " "))
     println(sb)
  }

}

import java.util.StringTokenizer

object _285A extends App {
  var token = new StringTokenizer("")
  def next = {
    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)
    token.nextToken()
  }
  val n = next.toInt
  val k = next.toInt
  val a = (1 to n).toArray

  def reverse(l: Int, r: Int): Unit = {
    if (l < r) {
      val cb = a(l)
      a(l) = a(r)
      a(r) = cb
    }
  }

  reverse(0, k)
  println(a.mkString(" "))
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, k) = in.next().split(" ").map(_.toInt)
  val r = (k + 1 to n).toList ::: (1 until (k)).toList ::: List(k)
  println(r.mkString(" "))
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, k) = in.next().split(" ").map(_.toInt)
  val r = (n - k + 1 to n).toList ::: List(n - k) ::: (1 until (n - k)).toList
  println(r.mkString(" "))
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, k) = in.next().split(" ").map(_.toInt)
  val r = (n to k + 2 by -1).toList ::: (1 until (k + 2)).toList
  println(r.mkString(" "))
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, k) = in.next().split(" ").map(_.toInt)
  val r = (n - k + 1 to n).toList ::: (1 until (n - k)).toList ::: List(n - k)
  println(r.mkString(" "))
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, k) = in.next().split(" ").map(_.toInt)
  val r = (1 until (n - k)).toList ::: (n - k + 1 to n).toList ::: List(n - k)
  println(r.mkString(" "))
}

import scala.io._
import java.util.StringTokenizer
import java.io.BufferedReader

object Main {

    def main(args: Array[String]): Unit = {
        val N = nextInt
        val K = nextInt
        1 to (N - K) foreach println
        N to K by -1 foreach println
    }

    class Tokenizer(in: BufferedReader, splitOn: String = " \n\t\r\f")
    {
        private var tokenizer = new StringTokenizer("")
        def readLine() = in.readLine()
        def nextToken(): String = {
            while (!tokenizer.hasMoreTokens) {
                val line = readLine
                if (line == null) return null
                tokenizer = new StringTokenizer(line, splitOn)
            }
            tokenizer.nextToken
        }
        def next[A](f: String => A) = f(nextToken)
        def nextSeq[A](f: () => A, count: Int) = (for (i <- 0 until count) yield f())
    }

    implicit val tokenizer = new Tokenizer(Console.in)

    def nextInt()(implicit t: Tokenizer) = t.next(_.toInt)
    def nextLong()(implicit t: Tokenizer) = t.next(_.toLong)
    def nextDouble()(implicit t: Tokenizer) = t.next(_.toDouble)
    def nextBigInt()(implicit t: Tokenizer) = t.next(BigInt(_))
    def nextSeq[A](f: () => A, count: Int = nextInt())(implicit t: Tokenizer) =
        (for (i <- 0 until count) yield f())
}

import scala.io._
import java.util.StringTokenizer
import java.io.BufferedReader

object Main {

    def main(args: Array[String]): Unit = {
        val N = nextInt
        val K = nextInt
        K to 1 by -1 foreach println
        (K+1) to N foreach println
    }

    class Tokenizer(in: BufferedReader, splitOn: String = " \n\t\r\f")
    {
        private var tokenizer = new StringTokenizer("")
        def readLine() = in.readLine()
        def nextToken(): String = {
            while (!tokenizer.hasMoreTokens) {
                val line = readLine
                if (line == null) return null
                tokenizer = new StringTokenizer(line, splitOn)
            }
            tokenizer.nextToken
        }
        def next[A](f: String => A) = f(nextToken)
        def nextSeq[A](f: () => A, count: Int) = (for (i <- 0 until count) yield f())
    }

    implicit val tokenizer = new Tokenizer(Console.in)

    def nextInt()(implicit t: Tokenizer) = t.next(_.toInt)
    def nextLong()(implicit t: Tokenizer) = t.next(_.toLong)
    def nextDouble()(implicit t: Tokenizer) = t.next(_.toDouble)
    def nextBigInt()(implicit t: Tokenizer) = t.next(BigInt(_))
    def nextSeq[A](f: () => A, count: Int = nextInt())(implicit t: Tokenizer) =
        (for (i <- 0 until count) yield f())
}


Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1, r1], [l2, r2], ..., [ln, rn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1, rn].

The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1 ≤ n ≤ 100, 0 ≤ P1, P2, P3 ≤ 100, 1 ≤ T1, T2 ≤ 60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0 ≤ li < ri ≤ 1440, ri < li + 1 for i < n), which stand for the start and the end of the i-th period of work.

//package me.jetblack.cf

import java.util.Scanner

object PowerUsage extends App {

  val s = new Scanner(System.in)

  import s._

  val (n, p1, p2, p3, t1, t2) = (nextInt(), nextInt(), nextInt(), nextInt(), nextInt(), nextInt())
  var intervals = (0 until n).map(_ => (nextInt(), nextInt()))
  intervals = intervals ++ List((intervals.last._2, intervals.last._2))
  var pow = 0

  for (
    (i1, i2) :: (i3, i4) :: _ <- intervals.sliding(2).toList.map(_.toList)
  ) yield {
    pow += p1 * (i2 - i1)
    //pow += p1 * (i4 - i3)
    val d = i3 - i2
    if (d > t1) {
      pow += t1 * p1
      val d1 = d - t1
      if (d1 > t2) {
        pow += t2 * p2
        val d2 = (d1 - t2)
        pow += d2 * p3
      } else {
        pow += d1 * p2
      }
    } else {
      pow += d * p1
    }
  }

  println(pow)

}

import java.util._
import java.lang._
import java.io._

object A {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

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

  def nextInt: Int = {
    return Integer.parseInt(next)
  }

  def nextLong: Long = {
    return Long.parseLong(next)
  }

  def solve = {
    val n = nextInt
    val p1 = nextInt
    val p2 = nextInt
    val p3 = nextInt
    val t1 = nextInt
    val t2 = nextInt
    var result = 0
    var prev = 0
    for (i <- 0 until n) {
      val l = nextInt
      val r = nextInt
      if (i == 0) {
        prev = l
      }
      result += (r - l) * p1
      if (l - t1 > prev) {
        result += t1 * p1
        if (l - t1 - t2 > prev) {
          result += t2 * p2
          result += (l - t1 - t2 - prev) * p3
        } else {
          result += (l - prev - t1) * p2
        }
      } else {
        result += (l - prev) * p1
      }
      prev = r
    }
    out.println(result)
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}

//package me.jetblack.cf

import java.util.Scanner

object PowerUsage extends App {

  val s = new Scanner(System.in)

  import s._

  val (n, p1, p2, p3, t1, t2) = (nextInt(), nextInt(), nextInt(), nextInt(), nextInt(), nextInt())
  var intervals = (0 until n).map(_ => (nextInt(), nextInt()))
  if (intervals.size == 1) {
    intervals = intervals ++ List((intervals.head._2, intervals.head._2))
  }
  var pow = 0

  for (
    Seq((i1, i2), (i3, i4)) <- intervals.sliding(2).toSeq
  ) yield {
    pow += p1 * (i2 - i1)
    pow += p1 * (i4 - i3)
    val d = i3 - i2
    if (d > t1) {
      pow += t1 * p1
      val d1 = d - t1
      if (d1 > t2) {
        pow += t2 * p2
        val d2 = (d1 - t2)
        pow += d2 * p3
      } else {
        pow += d1 * p2
      }
    } else {
      pow += d * p1
    }
  }

  println(pow)

}


There is a trampoline park with $$$n$$$ trampolines in a line. The $$$i$$$-th of which has strength $$$S_i$$$.Pekora can jump on trampolines in multiple passes. She starts the pass by jumping on any trampoline of her choice. If at the moment Pekora jumps on trampoline $$$i$$$, the trampoline will launch her to position $$$i + S_i$$$, and $$$S_i$$$ will become equal to $$$\max(S_i-1,1)$$$. In other words, $$$S_i$$$ will decrease by $$$1$$$, except of the case $$$S_i=1$$$, when $$$S_i$$$ will remain equal to $$$1$$$. If there is no trampoline in position $$$i + S_i$$$, then this pass is over. Otherwise, Pekora will continue the pass by jumping from the trampoline at position $$$i + S_i$$$ by the same rule as above.Pekora can't stop jumping during the pass until she lands at the position larger than $$$n$$$ (in which there is no trampoline). Poor Pekora!Pekora is a naughty rabbit and wants to ruin the trampoline park by reducing all $$$S_i$$$ to $$$1$$$. What is the minimum number of passes she needs to reduce all $$$S_i$$$ to $$$1$$$?

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 500$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 5000$$$) — the number of trampolines. The second line of each test case contains $$$n$$$ integers $$$S_1, S_2, \dots, S_n$$$ ($$$1 \le S_i \le 10^9$$$), where $$$S_i$$$ is the strength of the $$$i$$$-th trampoline. It's guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$5000$$$.

For each test case, output a single integer — the minimum number of passes Pekora needs to do to reduce all $$$S_i$$$ to $$$1$$$.

NoteFor the first test case, here is an optimal series of passes Pekora can take. (The bolded numbers are the positions that Pekora jumps into during these passes.)  $$$[1,4,\textbf{2},2,\textbf{2},2,\textbf{2}]$$$  $$$[1,\textbf{4},1,2,1,\textbf{2},1]$$$  $$$[1,\textbf{3},1,2,\textbf{1},\textbf{1},\textbf{1}]$$$  $$$[1,\textbf{2},1,\textbf{2},1,\textbf{1},\textbf{1}]$$$ For the second test case, the optimal series of passes is show below.  $$$[\textbf{2},3]$$$  $$$[1,\textbf{3}]$$$  $$$[1,\textbf{2}]$$$ For the third test case, all $$$S_i$$$ are already equal to $$$1$$$.

object C2 {
  import InOut._
  def main(args: Array[String]): Unit = {
    val t = nextInt
    val ress = Array.ofDim[Long](t)

    for (test <- 0 until t) {
      val n = nextInt
      val as = nextInts(n)
      val incomings = Array.fill(n){ 0 }
      var res = 0L

      for (i <- as.indices) {
        res += Math.max(0, as(i) - incomings(i) - 1)
        if (as(i) > n) {
          val d = as(i) - n
          incomings(i) = Math.max(incomings(i) - d, 0)
          as(i) = n
        }
        while (as(i) > 1) {
          val j = i + as(i)
          if (j < n) {
            incomings(j) += 1
          }
          incomings(i) -= 1
          as(i) -= 1
        }
        if (i + 1 < n && incomings(i) > 0) {
          incomings(i + 1) += incomings(i)
        }
      }

      ress(test) = res
    }

    out.println(ress.mkString("\n"))
    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 C2 {
  import InOut._
  def main(args: Array[String]): Unit = {
    val t = nextInt
    val ress = Array.ofDim[Long](t)

    for (test <- 0 until t) {
      val n = nextInt
      val as = nextInts(n)
      val incomings = Array.fill(n){ 0 }
      var res = 0L

      for (i <- as.indices) {
        res += Math.max(0, as(i) - incomings(i) - 1)
        if (as(i) > n) {
          val d = n - as(i)
          incomings(i) = Math.max(incomings(i) - d, 0)
          as(i) = n
        }
        while (as(i) > 1) {
          val j = i + as(i)
          if (j < n) {
            incomings(j) += 1
          }
          incomings(i) -= 1
          as(i) -= 1
        }
        if (i + 1 < n && incomings(i) > 0) {
          incomings(i + 1) += incomings(i)
        }
      }

      ress(test) = res
    }

    out.println(ress.mkString("\n"))
    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 C2 {
  import InOut._
  def main(args: Array[String]): Unit = {
    val t = nextInt
    val ress = Array.ofDim[Long](t)

    for (test <- 0 until t) {
      val n = nextInt
      val as = nextInts(n)
      val incomings = Array.fill(n){ 0 }
      var res = 0L

      for (i <- as.indices) {
        res += Math.max(0, as(i) - incomings(i) - 1)
        if (as(i) > n) {
          val d = n - as(i)
          incomings(i) = Math.min(incomings(i) - d, 0)
          as(i) = n
        }
        while (as(i) > 1) {
          val j = i + as(i)
          if (j < n) {
            incomings(j) += 1
          }
          incomings(i) -= 1
          as(i) -= 1
        }
        if (i + 1 < n && incomings(i) > 0) {
          incomings(i + 1) += incomings(i)
        }
      }

      ress(test) = res
    }

    out.println(ress.mkString("\n"))
    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 C2 {
  import InOut._
  def main(args: Array[String]): Unit = {
    val t = nextInt
    val ress = Array.ofDim[Long](t)

    for (test <- 0 until t) {
      val n = nextInt
      val as = nextInts(n)
      val incomings = Array.fill(n){ 0 }
      var res = 0L

      for (i <- as.indices) {
        res += Math.max(0, as(i) - incomings(i) - 1)
        if (as(i) > n) {
          incomings(i) = Math.min(incomings(i), as(i) - n - 1)
          as(i) = n
        }
//        if (incomings(i) < as(i)) {
//          incomings(i) = as(i) - 1
//        }
        while (as(i) > 1) {
          val j = i + as(i)
          if (j < n) {
            incomings(j) += 1
          }
          incomings(i) -= 1
          as(i) -= 1
        }
        if (i + 1 < n && incomings(i) > 0) {
          incomings(i + 1) += incomings(i)
        }
      }

      ress(test) = res
    }

    out.println(ress.mkString("\n"))
    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 C2 {
  import InOut._
  def main(args: Array[String]): Unit = {
    val t = nextInt
    val ress = Array.ofDim[Long](t)

    for (test <- 0 until t) {
      val n = nextInt
      val as = nextInts(n)
      val incomings = Array.fill(n){ 0 }
      var res = 0L

      for (i <- as.indices) {
        res += Math.max(0, as(i) - incomings(i) - 1)
        if (as(i) > n) {
          incomings(i) = Math.min(incomings(i), as(i) - n)
          as(i) = n
        }
//        if (incomings(i) < as(i)) {
//          incomings(i) = as(i) - 1
//        }
        while (as(i) > 1) {
          val j = i + as(i)
          if (j < n) {
            incomings(j) += 1
          }
          incomings(i) -= 1
          as(i) -= 1
        }
        if (i + 1 < n && incomings(i) > 0) {
          incomings(i + 1) += incomings(i)
        }
      }

      ress(test) = res
    }

    out.println(ress.mkString("\n"))
    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 C2 {
  import InOut._
  def main(args: Array[String]): Unit = {
    val t = nextInt
    val ress = Array.ofDim[Long](t)

    for (test <- 0 until t) {
      val n = nextInt
      val as = nextInts(n)
      val incomings = Array.fill(n){ 0 }
      var res = 0L

      for (i <- as.indices) {
        res += Math.max(0, as(i) - incomings(i) - 1)
        if (as(i) > n) {
          incomings(i) = Math.min(incomings(i), as(i) - n)
          as(i) = n
        }
        if (incomings(i) < as(i)) {
          incomings(i) = as(i) - 1
        }
        while (as(i) > 1) {
          val j = i + as(i)
          if (j < n) {
            incomings(j) += 1
          }
          incomings(i) -= 1
          as(i) -= 1
        }
        if (i + 1 < n) {
          incomings(i + 1) += incomings(i)
        }
      }

      ress(test) = res
    }

    out.println(ress.mkString("\n"))
    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 C2 {
  import InOut._
  def main(args: Array[String]): Unit = {
    val t = nextInt
    val ress = Array.ofDim[Long](t)

    for (test <- 0 until t) {
      val n = nextInt
      val as = nextInts(n)
      val incomings = Array.fill(n){ 0 }
      var res = 0L

      for (i <- as.indices) {
        res += Math.max(0, as(i) - incomings(i) - 1)
        if (as(i) > n) {
          as(i) = n
        }
        if (incomings(i) < as(i)) {
          incomings(i) = as(i) - 1
        }
        while (as(i) > 1) {
          val j = i + as(i)
          if (j < n) {
            incomings(j) += 1
          }
          incomings(i) -= 1
          as(i) -= 1
        }
        if (i + 1 < n) {
          incomings(i + 1) += incomings(i)
        }
      }

      ress(test) = res
    }

    out.println(ress.mkString("\n"))
    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 C2 {
  import InOut._
  def main(args: Array[String]): Unit = {
    val t = nextInt
    val ress = Array.ofDim[Long](t)

    for (test <- 0 until t) {
      val n = nextInt
      val as = nextInts(n)
      val incomings = Array.fill(n){ 0 }
      var res = 0L

      for (i <- as.indices) {
        res += Math.max(0, as(i) - incomings(i) - 1)
        if (as(i) > n - i) {
          as(i) = n - i
        }
        if (incomings(i) < as(i)) {
          incomings(i) = as(i) - 1
        }
        while (as(i) > 1) {
          val j = i + as(i)
          if (j < n) {
            incomings(j) += 1
          }
          incomings(i) -= 1
          as(i) -= 1
        }
        if (i + 1 < n) {
          incomings(i + 1) += incomings(i)
        }
      }

      ress(test) = res
    }

    out.println(ress.mkString("\n"))
    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 C2 {
  import InOut._
  def main(args: Array[String]): Unit = {
    val t = nextInt
    val ress = Array.ofDim[Long](t)

    for (test <- 0 until t) {
      val n = nextInt
      val as = nextInts(n)
      val incomings = Array.fill(n){ 0 }
      var res = 0L
      if (as(0) > 1) {
        res += as(0) - 1
        incomings(0) = as(0) - 1
      }

      for (i <- as.indices) {
        if (as(i) > incomings(i)) {
          res += as(i) - incomings(i)
        }
        while (as(i) > 1) {
          val j = i + as(i)
          if (j < n) {
            incomings(j) += 1
          }
          incomings(i) -= 1
          as(i) -= 1
        }
        if (i + 1 < n) {
          incomings(i + 1) += incomings(i)
        }
      }

      ress(test) = res
    }

    out.println(ress.mkString("\n"))
    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 C {
  import InOut._
  def main(args: Array[String]): Unit = {
    val t = nextInt
    val ress = Array.ofDim[Long](t)
    for (i <- 0 until t) {
      val n = nextInt
      val as = nextInts(n)
//            val as = Array.fill(n)(1000000000)
      var res = 0L
      var numOnes = 0
      val skipTo = Array.ofDim[Int](n)
      for (i <- as.indices) {
        skipTo(i) = i + 1
        val nn = 2*n  // 2//2*Math.sqrt(i).toInt + 1
        if (as(i) > nn) {
          res += as(i) - nn
          as(i) = nn
        }
        if (as(i) == 1) numOnes += 1
      }
      var start = 0
      while (numOnes < n) {
        //        println(res, as.mkString(" "))
        res += 1
        while (start + 1 < n && as(start) == 1 && as(start + 1) == 1) start += 1
        var i = start
        while (i < n) {
          if (as(i) > 1) {
            val nextI = i + as(i)
            as(i) -= 1
            if (as(i) == 1) numOnes += 1
            i = nextI
          } else {
            while (skipTo(i) < n && as(skipTo(i)) == 1) skipTo(i) = skipTo(skipTo(i))
            i = skipTo(i)
          }
        }
      }

      ress(i) = res
    }

    out.println(ress.mkString("\n"))
    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 C {
  import InOut._
  def main(args: Array[String]): Unit = {
    val t = nextInt
    val ress = Array.ofDim[Long](t)
    for (i <- 0 until t) {
      val n = nextInt
      val as = nextInts(n)
//            val as = Array.fill(n)(1000000000)
      var res = 0L
      var numOnes = 0
      val skipTo = Array.ofDim[Int](n)
      for (i <- as.indices) {
        skipTo(i) = i + 1
        val nn = n + i // 2//2*Math.sqrt(i).toInt + 1
        if (as(i) > nn) {
          res += as(i) - nn
          as(i) = nn
        }
        if (as(i) == 1) numOnes += 1
      }
      var start = 0
      while (numOnes < n) {
        //        println(res, as.mkString(" "))
        res += 1
        while (start + 1 < n && as(start) == 1 && as(start + 1) == 1) start += 1
        var i = start
        while (i < n) {
          if (as(i) > 1) {
            val nextI = i + as(i)
            as(i) -= 1
            if (as(i) == 1) numOnes += 1
            i = nextI
          } else {
            while (skipTo(i) < n && as(skipTo(i)) == 1) skipTo(i) = skipTo(skipTo(i))
            i = skipTo(i)
          }
        }
      }

      ress(i) = res
    }

    out.println(ress.mkString("\n"))
    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 C {
  import InOut._
  def main(args: Array[String]): Unit = {
    val t = nextInt
    val ress = Array.ofDim[Long](t)
    for (i <- 0 until t) {
      val n = nextInt
      val as = nextInts(n)
//            val as = Array.fill(n)(1000000000)
      var res = 0L
      var numOnes = 0
      val skipTo = Array.ofDim[Int](n)
      for (i <- as.indices) {
        skipTo(i) = i + 1
        val nn = n + i / 2//2*Math.sqrt(i).toInt + 1
        if (as(i) > nn) {
          res += as(i) - nn
          as(i) = nn
        }
        if (as(i) == 1) numOnes += 1
      }
      var start = 0
      while (numOnes < n) {
        //        println(res, as.mkString(" "))
        res += 1
        while (start + 1 < n && as(start) == 1 && as(start + 1) == 1) start += 1
        var i = start
        while (i < n) {
          if (as(i) > 1) {
            val nextI = i + as(i)
            as(i) -= 1
            if (as(i) == 1) numOnes += 1
            i = nextI
          } else {
            while (skipTo(i) < n && as(skipTo(i)) == 1) skipTo(i) = skipTo(skipTo(i))
            i = skipTo(i)
          }
        }
      }

      ress(i) = res
    }

    out.println(ress.mkString("\n"))
    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 C {
  import InOut._
  def main(args: Array[String]): Unit = {
    for (_ <- 1 to nextInt) {
      val n = nextInt
      val as = nextInts(n)
//            val as = Array.fill(n)(1000000000)
      var res = 0L
      var numOnes = 0
      val skipTo = Array.ofDim[Int](n)
      for (i <- as.indices) {
        skipTo(i) = i + 1
        val nn = n + 2*Math.sqrt(i).toInt + 1
        if (as(i) > nn) {
          res += as(i) - nn
          as(i) = nn
        }
        if (as(i) == 1) numOnes += 1
      }
      var start = 0
      while (numOnes < n) {
        //        println(res, as.mkString(" "))
        res += 1
        while (start + 1 < n && as(start) == 1 && as(start + 1) == 1) start += 1
        var i = start
        while (i < n) {
          if (as(i) > 1) {
            val nextI = i + as(i)
            as(i) -= 1
            if (as(i) == 1) numOnes += 1
            i = nextI
          } else {
            while (skipTo(i) < n && as(skipTo(i)) == 1) skipTo(i) = skipTo(skipTo(i))
            i = skipTo(i)
          }
        }
      }

      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 C {
  import InOut._
  def main(args: Array[String]): Unit = {
    for (_ <- 1 to nextInt) {
      val n = nextInt
      val as = nextInts(n)
//            val as = Array.fill(n)(1000000000)
      var res = 0L
      var numOnes = 0
      val skipTo = Array.ofDim[Int](n)
      for (i <- as.indices) {
        skipTo(i) = i + 1
        val nn = n + Math.sqrt(i).toInt + 1
        if (as(i) > nn) {
          res += as(i) - nn
          as(i) = nn
        }
        if (as(i) == 1) numOnes += 1
      }
      var start = 0
      while (numOnes < n) {
        //        println(res, as.mkString(" "))
        res += 1
        while (start + 1 < n && as(start) == 1 && as(start + 1) == 1) start += 1
        var i = start
        while (i < n) {
          if (as(i) > 1) {
            val nextI = i + as(i)
            as(i) -= 1
            if (as(i) == 1) numOnes += 1
            i = nextI
          } else {
            while (skipTo(i) < n && as(skipTo(i)) == 1) skipTo(i) = skipTo(skipTo(i))
            i = skipTo(i)
          }
        }
      }

      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 C {
  import InOut._
  def main(args: Array[String]): Unit = {
    for (_ <- 1 to nextInt) {
      val n = nextInt
      val as = nextInts(n)
//            val as = Array.fill(n)(1000000000)
      var res = 0L
      var numOnes = 0
      val skipTo = Array.ofDim[Int](n)
      for (i <- as.indices) {
        skipTo(i) = i + 1
        val nn = n + (32 - Integer.numberOfLeadingZeros(i + 1))
        if (as(i) > nn) {
          res += as(i) - nn
          as(i) = nn
        }
        if (as(i) == 1) numOnes += 1
      }
      var start = 0
      while (numOnes < n) {
        //        println(res, as.mkString(" "))
        res += 1
        while (start + 1 < n && as(start) == 1 && as(start + 1) == 1) start += 1
        var i = start
        while (i < n) {
          if (as(i) > 1) {
            val nextI = i + as(i)
            as(i) -= 1
            if (as(i) == 1) numOnes += 1
            i = nextI
          } else {
            while (skipTo(i) < n && as(skipTo(i)) == 1) skipTo(i) = skipTo(skipTo(i))
            i = skipTo(i)
          }
        }
      }

      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 C {
  import InOut._
  def main(args: Array[String]): Unit = {
    for (_ <- 1 to nextInt) {
      val n = nextInt
      val as = nextInts(n)
//            val as = Array.fill(n)(1000000000)
      var res = 0L
      var numOnes = 0
      val skipTo = Array.ofDim[Int](n)
      for (i <- as.indices) {
        skipTo(i) = i + 1
        val nn = 2 * n
        if (as(i) > nn) {
          res += as(i) - nn
          as(i) = nn
        }
        if (as(i) == 1) numOnes += 1
      }
      var start = 0
      while (numOnes < n) {
        //        println(res, as.mkString(" "))
        res += 1
        while (start + 1 < n && as(start) == 1 && as(start + 1) == 1) start += 1
        var i = start
        while (i < n) {
          if (as(i) > 1) {
            val nextI = i + as(i)
            as(i) -= 1
            if (as(i) == 1) numOnes += 1
            i = nextI
          } else {
            while (skipTo(i) < n && as(skipTo(i)) == 1) skipTo(i) += 1
            i = skipTo(i)
          }
        }
      }

      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 C {
  import InOut._
  def main(args: Array[String]): Unit = {
    for (_ <- 1 to nextInt) {
      val n = nextInt
      val as = nextInts(n)
//            val as = Array.fill(n)(1000000000)
      var res = 0L
      var numOnes = 0
      val skipTo = Array.ofDim[Int](n)
      for (i <- as.indices) {
        skipTo(i) = i + 1
        val nn = n + i
        if (as(i) > nn) {
          res += as(i) - nn
          as(i) = nn
        }
        if (as(i) == 1) numOnes += 1
      }
      var start = 0
      while (numOnes < n) {
        //        println(res, as.mkString(" "))
        res += 1
        while (start + 1 < n && as(start) == 1 && as(start + 1) == 1) start += 1
        var i = start
        while (i < n) {
          if (as(i) > 1) {
            val nextI = i + as(i)
            as(i) -= 1
            if (as(i) == 1) numOnes += 1
            i = nextI
          } else {
            while (skipTo(i) < n && as(skipTo(i)) == 1) skipTo(i) += 1
            i = skipTo(i)
          }
        }
      }

      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 C {
  import InOut._
  def main(args: Array[String]): Unit = {
    for (_ <- 1 to nextInt) {
      val n = nextInt
      val as = nextInts(n)
//            val as = Array.fill(n)(1000000000)
      var res = 0L
      for (i <- as.indices) {
        val nn = n + 1
        if (as(i) > nn) {
          res += as(i) - nn
          as(i) = nn
        }
      }
      var numOnes = as.count(_ == 1)
      var start = 0
      while (numOnes < n) {
        //        println(res, as.mkString(" "))
        res += 1
        while (start + 1 < n && as(start) == 1 && as(start + 1) == 1) start += 1
        var i = start
        while (i < n) {
          val nextI = i + as(i)
          if (as(i) > 1) {
            as(i) -= 1
            if (as(i) == 1) numOnes += 1
          }
          i = nextI
        }
      }

      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 C {
  import InOut._
  def main(args: Array[String]): Unit = {
    for (_ <- 1 to nextInt) {
      val n = nextInt
//      val as = nextInts(n)
            val as = Array.fill(n)(1000000000)
      var res = 0L
      for (i <- as.indices) {
        val nn = n + 10
        if (as(i) > nn) {
          res += as(i) - nn
          as(i) = nn
        }
      }
      var numOnes = as.count(_ == 1)
      var start = 0
      while (numOnes < n) {
        //        println(res, as.mkString(" "))
        res += 1
        while (start + 1 < n && as(start) == 1 && as(start + 1) == 1) start += 1
        var i = start
        while (i < n) {
          val nextI = i + as(i)
          if (as(i) > 1) {
            as(i) -= 1
            if (as(i) == 1) numOnes += 1
          }
          i = nextI
        }
      }

      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 C {
  import InOut._
  def main(args: Array[String]): Unit = {
    for (_ <- 1 to nextInt) {
      val n = nextInt
      val as = nextInts(n)
//      val as = Array.fill(n)(1000000000)
      var res = 0L
      for (i <- as.indices) {
        val nn = n + i
        if (as(i) > nn) {
          res += as(i) - nn
          as(i) = nn
        }
      }
      var numOnes = as.count(_ == 1)
      var start = 0
      var changed = true
      res -= 1
      while (changed) {
        //        println(res, as.mkString(" "))
        res += 1
        while (start + 1 < n && as(start + 1) == 1) start += 1
        var i = start
        changed = false
        while (i < n) {
          val nextI = i + as(i)
          if (as(i) > 1) {
            as(i) -= 1
//            if (as(i) == 1) numOnes += 1
            changed = true
          }
          i = nextI
        }
      }

      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 C {
  import InOut._
  def main(args: Array[String]): Unit = {
    for (_ <- 1 to nextInt) {
      val n = nextInt
      val as = nextInts(n)
      var res = 0L
      for (i <- as.indices) {
        val nn = n//2 * n + i
        if (as(i) > nn) {
          res += as(i) - nn
          as(i) = nn
        }
      }
      var numOnes = as.count(_ == 1)
      var start = 0
      while (numOnes < n) {
        //        println(res, as.mkString(" "))
        res += 1
        while (as(start) == 1) start += 1
        var i = 0
        while (i < n) {
          val nextI = i + as(i)
          if (as(i) > 1) {
            as(i) -= 1
            if (as(i) == 1) numOnes += 1
          }
          i = nextI
        }
      }

      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 C {
  import InOut._
  def main(args: Array[String]): Unit = {
    for (_ <- 1 to nextInt) {
      val n = nextInt
      val as = nextInts(n)
      var res = 0L
      for (i <- as.indices) {
        val nn = (n - i) * 2 + n
        if (as(i) > nn) {
          res += as(i) - nn
          as(i) = nn
        }
      }
      while (as.max > 1) {
//        println(res, as.mkString(" "))
        res += 1
        var i = 0
        while (i < n) {
          val nextI = i + as(i)
          if (as(i) > 1) as(i) -= 1
          i = nextI
        }
      }
      res += (as.max - 1)

      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 C {
  import InOut._
  def main(args: Array[String]): Unit = {
    for (_ <- 1 to nextInt) {
      val n = nextInt
      val as = nextInts(n)
      var res = 0L
      for (i <- as.indices) {
        val nn = (n - i) * 2 + 1
        if (as(i) > nn) {
          res += as(i) - nn
          as(i) = nn
        }
      }
      while (as.max > 1) {
//        println(res, as.mkString(" "))
        res += 1
        var i = 0
        while (i < n) {
          val nextI = i + as(i)
          if (as(i) > 1) as(i) -= 1
          i = nextI
        }
      }
      res += (as.max - 1)

      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 C {
  import InOut._
  def main(args: Array[String]): Unit = {
    for (_ <- 1 to nextInt) {
      val n = nextInt
      val as = nextInts(n)
      var res = 0
      val nn = n * n
      for (i <- as.indices) {
        if (as(i) > nn) {
          res += as(i) - nn
          as(i) = nn
        }
      }
      while (as.max > 1) {
//        println(res, as.mkString(" "))
        res += 1
        var i = 0
        while (i < n) {
          val nextI = i + as(i)
          if (as(i) > 1) as(i) -= 1
          i = nextI
        }
      }
      res += (as.max - 1)

      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 C {
  import InOut._
  def main(args: Array[String]): Unit = {
    for (_ <- 1 to nextInt) {
      val n = nextInt
      val as = nextInts(n)
      var res = 0
      for (i <- as.indices) {
        if (as(i) > n) {
          res += as(i) - n
          as(i) = n
        }
      }
      while (as.max > 1) {
//        println(res, as.mkString(" "))
        res += 1
        var i = 0
        while (i < n) {
          val nextI = i + as(i)
          if (as(i) > 1) as(i) -= 1
          i = nextI
        }
      }
      res += (as.max - 1)

      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
  }
}


While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bitwise AND is equal to s. As this number can be large, output it modulo 109 + 7.To represent the string as a number in numeral system with base 64 Vanya uses the following rules:  digits from '0' to '9' correspond to integers from 0 to 9;  letters from 'A' to 'Z' correspond to integers from 10 to 35;  letters from 'a' to 'z' correspond to integers from 36 to 61;  letter '-' correspond to integer 62;  letter '_' correspond to integer 63.

The only line of the input contains a single word s (1 ≤ |s| ≤ 100 000), consisting of digits, lowercase and uppercase English letters, characters '-' and '_'.

Print a single integer — the number of possible pairs of words, such that their bitwise AND is equal to string s modulo 109 + 7.

NoteFor a detailed definition of bitwise AND we recommend to take a look in the corresponding article in Wikipedia.In the first sample, there are 3 possible solutions:   z&_ = 61&63 = 61 = z  _&z = 63&61 = 61 = z  z&z = 61&61 = 61 = z

import Utils._, annotation.tailrec, collection.mutable, util._, control._, math.Ordering.Implicits._

object _677C extends CodeForcesApp {
  override def apply(io: IO) = {
    val s = io[String]
    val num = s map {c =>
      if(c >= '0' && c <= '9') {
        c - '0' + 0
      } else if (c >= 'A' && c <= 'Z') {
        c - 'A' + 10
      } else if (c >= 'a' && c <= 'z') {
        c - 'a' + 36
      } else if (c == '-') {
        62
      } else {
        63
      }
    }
    val zeroes = num.sumWith(i => 6 - i.bitCount)
    io += BigInt(3).modPow(zeroes, mod)
  }
}
/****************************[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()
}
object Utils {
  import scala.collection.mutable, mutable.{Map => Dict}
  implicit class GenericExtensions[A](val a: A) extends AnyVal {
    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a
  }
  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {
    def onlyElement: A = t.head.ensuring(t.size == 1)
    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)
    def duplicates(implicit b: C of A): C[A] = {
      val elems = mutable.Set.empty[A]
      (t collect {case i if !elems.add(i) => i}).to[C]
    }
    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}
    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]
    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap
    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)
    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}
    def toMutableMultiSet: Dict[A, Int] = {
      val c = map[A] to 0
      t.foreach(i => c(i) += 1)
      c
    }
    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0
  }
  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)
  }
  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)
  }
  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {
    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t
  }
  implicit class PairExtensions[A, B](val p: (A, B)) extends AnyVal {
    def key = p._1
    def value = p._2
  }
  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {
    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_.key).mapValues(_.value)
    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_.key).mapValues(_.map(_.value).to[C])
    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]
  }
  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {
    def lastKeyOption: Option[K] = m.lastOption.map(_.key)
    def firstKeyOption: Option[K] = m.headOption.map(_.key)
    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap
    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}
    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m
  }
  implicit class MutableMapExtensions[K, V](val m: mutable.Map[K, V]) extends AnyVal {
    def removeLast(): Option[(K, V)] = m.lastOption.map(removeNode)
    def removeFirst(): Option[(K, V)] = m.headOption.map(removeNode)
    private def removeNode(kv: (K, V)): (K, V) = {
      m -= kv.key
      kv
    }
  }
  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {
    def notContains(x: A): Boolean = !(s contains x)
    def toMutable = mutable.Set.empty[A] ++ s
  }
  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {
    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}
    def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f) findWithIndex c
  }
  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {
    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero
  }
  implicit class IntExtensions(val x: Int) extends AnyVal {
    def bitCount: Int = java.lang.Integer.bitCount(x)
  }
  implicit class LongExtensions(val x: Long) extends AnyVal {
    def bitCount: Int = java.lang.Long.bitCount(x)
  }
  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {
    import Numeric.Implicits._
    def **(i: Int): A = if (i == 0) n.one else {
      val h = x ** (i/2)
      if (i%2 == 0) h * h else h * h * x
    }
    def distance(y: A) = (x - y).abs()
    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)
    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students indexOf "Greg" whenNegative Int.MaxValue
  }
  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {
    import scala.collection.immutable.NumericRange, Integral.Implicits._
    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x
    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(n.min(x, y), n.max(x, y), n.one)
    def ceilDiv(y: A): A = if (mod(y) == n.zero) x/y else n.one + (x/y)
  }
  implicit def toPoint[A](p: (A, A))(implicit n: Numeric[A]) = new java.awt.geom.Point2D.Double(n.toDouble(p._1), n.toDouble(p._2))
  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)
  def asc[A](implicit order: Ordering[A]): Ordering[A] = order
  def map[K] = new {
    def to[V](default: V): Dict[K, V] = Dict.empty[K, V] withDefaultValue default // also to(Dict.empty[K2, V])
  }
  def memoize[A, B](f: A => B): collection.Map[A, B] = new mutable.HashMap[A, B]() {
    override def apply(key: A) = getOrElseUpdate(key, f(key))
  }
  implicit class FuzzyDouble(val x: Double) extends AnyVal {
    def  >~(y: Double) = x > y + eps
    def >=~(y: Double) = x >= y + eps
    def  ~<(y: Double) = y >=~ x
    def ~=<(y: Double) = y >~ x
    def  ~=(y: Double) = (x distance y) <= eps
  }
  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) Some(f) else None
  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)
  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]
  val mod: Int = (1e9 + 7).toInt
  val eps: Double = 1e-9
}
/***********************************[Scala I/O]*********************************************/
import Utils._, java.io._, java.util.StringTokenizer

class IO(in: BufferedReader, out: BufferedWriter) extends PrintWriter(out, true) with Iterator[String] {
  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

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

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

  def till(delim: String): String = tokenizer().get.nextToken(delim)
  def tillEndOfLine(): String = till("\n\r")

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

  var separator = " "
  private[this] var isNewLine = true

  def +=[A](x: A)(implicit write: IO.Write[A]): this.type = {
    write(this)(x)
    this
  }
  def ++=[A: IO.Write](xs: Traversable[A]): this.type = (this += xs.size) appendNewLine xs

  def appendNewLine[A: IO.Write](x: A): this.type = {
    println()
    this += x
  }

  override def print(obj: String) = {
    if (isNewLine) isNewLine = false else super.print(separator)
    super.print(obj)
  }
  override def println() = if (!isNewLine) {
    super.println()
    isNewLine = true
  }
  override def close() = {
    flush()
    in.close()
    super.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: C of A): Read[C[A]]         = new Read(r => r[C, A](r[Int]))
    implicit val string                                       : Read[String]       = new Read(_.next())
    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)
    implicit val boolean                                      : Read[Boolean]      = string.map(_.toBoolean)
    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[A], r[B]))
    implicit def tuple3[A: Read, B: Read, C: Read]            : Read[(A, B, C)]    = new Read(r => (r[A], r[B], r[C]))
    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]   : Read[(A, B, C, D)] = new Read(r => (r[A], r[B], r[C], r[D]))
  }
  trait Write[-A] {
    def apply(out: PrintWriter)(x: A): Unit
  }
  trait DefaultWrite {
    implicit def any[A]: Write[A] = Write(_.toString)
  }
  object Write extends DefaultWrite {
    def apply[A](f: A => String) = new Write[A] {
      override def apply(out: PrintWriter)(x: A) = out.print(f(x))
    }
    implicit val boolean: Write[Boolean] = Write(b => if (b) "YES" else "NO")
    implicit def tuple2[A, B]: Write[(A, B)] = Write {case (a, b) => s"$a $b"}
    implicit def array[A]: Write[Array[A]] = Write(_ mkString " ")
    implicit def iterable[A](implicit write: Write[A]): Write[Traversable[A]] = new Write[Traversable[A]] {
      override def apply(out: PrintWriter)(xs: Traversable[A]) = {
        xs foreach write(out)
        out.println()
      }
    }
  }
}

import Utils._, annotation.tailrec, collection.mutable, util._, control._, math.Ordering.Implicits._

object _677C extends CodeForcesApp {
  override def apply(io: IO) = {
    val s = io[String]
    val num = s map {c =>
      if(c >= '0' && c <= '9') {
        c - '0' + 0
      } else if (c >= 'A' && c <= 'Z') {
        c - 'A' + 10
      } else if (c >= 'a' && c <= 'z') {
        c - 'a' + 36
      } else if (c == '-') {
        62
      } else {
        63
      }
    }
    val ans = num.foldLeft(BigInt(1)) {case (p, n) =>
      val zeroes = 6 - n.bitCount
      val choices = BigInt(3).modPow(zeroes, mod)
      (p * choices) mod mod
    }

    io += 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()
}
object Utils {
  import scala.collection.mutable, mutable.{Map => Dict}
  implicit class GenericExtensions[A](val a: A) extends AnyVal {
    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a
  }
  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {
    def onlyElement: A = t.head.ensuring(t.size == 1)
    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)
    def duplicates(implicit b: C of A): C[A] = {
      val elems = mutable.Set.empty[A]
      (t collect {case i if !elems.add(i) => i}).to[C]
    }
    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}
    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]
    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap
    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)
    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}
    def toMutableMultiSet: Dict[A, Int] = {
      val c = map[A] to 0
      t.foreach(i => c(i) += 1)
      c
    }
    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0
  }
  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)
  }
  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)
  }
  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {
    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t
  }
  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {
    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_._1).mapValues(_._2)
    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_._1).mapValues(_.map(_._2).to[C])
    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]
  }
  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {
    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap
    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}
    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m
  }
  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {
    def notContains(x: A): Boolean = !(s contains x)
    def toMutable = mutable.Set.empty[A] ++ s
  }
  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {
    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}
    def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f) findWithIndex c
  }
  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {
    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero
  }
  implicit class LongExtensions(val x: Long) extends AnyVal {
    def bitCount: Int = java.lang.Long.bitCount(x)
  }
  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {
    import Numeric.Implicits._
    def **(i: Int): A = if (i == 0) n.one else {
      val h = x ** (i/2)
      if (i%2 == 0) h * h else h * h * x
    }
    def distance(y: A) = (x - y).abs()
    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)
    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students indexOf "Greg" whenNegative Int.MaxValue
  }
  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {
    import scala.collection.immutable.NumericRange, Integral.Implicits._
    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x
    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(n.min(x, y), n.max(x, y), n.one)
  }
  implicit def toPoint[A](p: (A, A))(implicit n: Numeric[A]) = new java.awt.geom.Point2D.Double(n.toDouble(p._1), n.toDouble(p._2))
  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)
  def asc[A](implicit order: Ordering[A]): Ordering[A] = order
  def map[K] = new {
    def to[V](default: V): Dict[K, V] = Dict.empty[K, V] withDefaultValue default // also to(Dict.empty[K2, V])
  }
  def memoize[A, B](f: A => B): collection.Map[A, B] = new mutable.HashMap[A, B]() {
    override def apply(key: A) = getOrElseUpdate(key, f(key))
  }
  implicit class FuzzyDouble(val x: Double) extends AnyVal {
    def  >~(y: Double) = x > y + eps
    def >=~(y: Double) = x >= y + eps
    def  ~<(y: Double) = y >=~ x
    def ~=<(y: Double) = y >~ x
    def  ~=(y: Double) = (x distance y) <= eps
  }
  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) Some(f) else None
  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)
  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]
  val mod: Int = (1e9 + 7).toInt
  val eps: Double = 1e-9
}
/***********************************[Scala I/O]*********************************************/
import Utils._, java.io._, java.util.StringTokenizer

class IO(in: BufferedReader, out: BufferedWriter) extends PrintWriter(out, true) with Iterator[String] {
  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

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

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

  def vector[A: IO.Read](n: Int): Vector[A] = apply[Vector, A](n)

  def till(delim: String): String = tokenizer().get.nextToken(delim)
  def tillEndOfLine(): String = till("\n\r")

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

  var separator = " "
  private[this] var isNewLine = true

  def +=[A](x: A)(implicit write: IO.Write[A]): this.type = {
    write(this)(x)
    this
  }
  def ++=[A: IO.Write](xs: Traversable[A]): this.type = (this += xs.size) appendNewLine xs

  def appendNewLine[A: IO.Write](x: A): this.type = {
    println()
    this += x
  }

  override def print(obj: String) = {
    if (isNewLine) isNewLine = false else super.print(separator)
    super.print(obj)
  }
  override def println() = if (!isNewLine) {
    super.println()
    isNewLine = true
  }
  override def close() = {
    flush()
    in.close()
    super.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: C of A): Read[C[A]]         = new Read(r => r[C, A](r[Int]))
    implicit val string                                       : Read[String]       = new Read(_.next())
    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)
    implicit val boolean                                      : Read[Boolean]      = string.map(_.toBoolean)
    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[A], r[B]))
    implicit def tuple3[A: Read, B: Read, C: Read]            : Read[(A, B, C)]    = new Read(r => (r[A], r[B], r[C]))
    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]   : Read[(A, B, C, D)] = new Read(r => (r[A], r[B], r[C], r[D]))
  }
  trait Write[-A] {
    def apply(out: PrintWriter)(x: A): Unit
  }
  trait DefaultWrite {
    implicit def any[A]: Write[A] = Write(_.toString)
  }
  object Write extends DefaultWrite {
    def apply[A](f: A => String) = new Write[A] {
      override def apply(out: PrintWriter)(x: A) = out.print(f(x))
    }
    implicit val boolean: Write[Boolean] = Write(b => if (b) "YES" else "NO")
    implicit def tuple2[A, B]: Write[(A, B)] = Write {case (a, b) => s"$a $b"}
    implicit def array[A]: Write[Array[A]] = Write(_ mkString " ")
    implicit def iterable[A](implicit write: Write[A]): Write[Traversable[A]] = new Write[Traversable[A]] {
      override def apply(out: PrintWriter)(xs: Traversable[A]) = {
        xs foreach write(out)
        out.println()
      }
    }
  }
}


An exam for n students will take place in a long and narrow room, so the students will sit in a line in some order. The teacher suspects that students with adjacent numbers (i and i + 1) always studied side by side and became friends and if they take an exam sitting next to each other, they will help each other for sure.Your task is to choose the maximum number of students and make such an arrangement of students in the room that no two students with adjacent numbers sit side by side.

A single line contains integer n (1 ≤ n ≤ 5000) — the number of students at an exam.

In the first line print integer k — the maximum number of students who can be seated so that no two students with adjacent numbers sit next to each other. In the second line print k distinct integers a1, a2, ..., ak (1 ≤ ai ≤ n), where ai is the number of the student on the i-th position. The students on adjacent positions mustn't have adjacent numbers. Formally, the following should be true: |ai - ai + 1| ≠ 1 for all i from 1 to k - 1. If there are several possible answers, output any of them.

object A524 extends App{

 var k = readInt
 var str = new StringBuilder
 k
  match {
   case 1 | 2 => println(1); println(1)
   case 3 => println(2); println(1 + " " + 3)
   case 4 => println(4); println("3 1 4 2")
   case 5 => println(5); println("1 4 2 5 3")
   case _ =>
     if (k % 2 == 0) {
       str.append(k + "\n")
       for (i <- 1 until k / 2 + 1)
         str.append(i + " " + (k/2 + i) + " ")
     }
     else {
       k -= 1
       str.append((k + 1) + "\n" + (k + 1) + " ")
       for (i <- 1 until k / 2 + 1)
         str.append(i + " " + (k/2 + i) + " ")
     }

     println(str.toString)
 }
}

import java.io._

object Main {

  val in = new BufferedReader(new InputStreamReader(System.in))
  val out = new PrintWriter(System.out)

  sys.addShutdownHook(out.close())

  @inline def nextInt = in.readLine().toInt
  @inline def nextInts = in.readLine().split(" +").map(_.toInt)
  @inline def println[T](x: T) = out.println(x)
  @inline def print[T](x: T) = out.print(x)

  def main(args: Array[String]): Unit = {
    val n = nextInt

    if (n <= 2)
      println("1\n1")
    else if (n == 3)
      println("2\n1 3")
    else {
      println(n)
      for (i ← (n + 1) / 2 to 1 by -1) print(s"${i + i - 1} ")
      for (i ← n / 2 to 1 by -1) print(s"${i + i} ")
    }
  }
}

/**
 * Author: Oleg Nizhnik
 * Date  : 14.04.2015
 * Time  : 16:01
 */

import scala.io.StdIn

object A extends App {
  val studs = StdIn.readInt() match {
    case 1 | 2 => List(1)
    case 3 => List(1, 3)
    case 4 => List(3, 1, 4, 2)
    case n if n % 2 == 1 => 1 to 2 * n by 2 map (_ % n + 1)
    case n => (1 to n by 2) ++ (2 to n by 2)
  }
  println(studs.length)
  println(studs mkString " ")
}

object A534 {

  import IO._

  def main(args: Array[String]): Unit = {
    val Array(n) = readInts(1)
    if(n <= 2) {
      println("1")
      println("1")
    } else if(n == 3){
      println("2")
      println("1 3")
    } else if(n == 4){
      println("4")
      println("3 1 4 2")
    } else {
      println(n)
      println(((1 to n by 2) ++ (2 to n by 2)).mkString(" "))
    }
  }

  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))
    }
  }

}

/**
 *
 * Created by ronaflx on 15-4-3.
 */

import java.io._
import java.util.StringTokenizer;
import Ordering.Implicits._;

object Codeforces {
  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

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

  def nextInt: Int = {
    Integer.parseInt(next)
  }

  def nextLong: Long = {
    java.lang.Long.parseLong(next)
  }

  def upperBound[T: Ordering](array: Array[T], value: T) = {
    var low = 0
    var high = array.length
    var res = array.length
    while (low <= high) {
      val mid = (low + high) / 2
      if (value < array(mid)) {
        res = mid
        high = mid - 1
      } else {
        low = mid + 1
      }
    }
    res
  }

  def solve(): Unit = {
    val n = nextInt
    println(if (n <= 3) (n + 1) / 2 else n)
    for (i <- Range(if ((n & 1) == 1) n else n - 1, 0, -2))
      print(i + " ")
    if (n >= 4) for (i <- Range(if ((n & 1) == 0) n else n - 1, 0, -2)) print(i + " ")
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}

object _534_A extends App {
  import java.util.Scanner

  import scala.collection.mutable

  lazy val file = getClass.getResourceAsStream(s"${getClass.getSimpleName.replace("$", "").last}.in")
  val in = if (submit) new Scanner(System.in) else new Scanner(file)

  while(in.hasNext) println(apply(parseInput))
  /******************************************************************************************************/
  def submit = true        // THIS MUST BE TRUE WHEN YOU SUBMIT !!!!

  type Input = Int

  def parseInput: Input = {
    import in._
    nextInt()
  }

  def apply(input: Input) = {
    val solution = input match {
      case 1 => List(1)
      case 2 => List(1)
      case 3 => List(1, 3)
      case 4 => List(3, 1, 4, 2)
      case n => List.tabulate((n+1)/2)(i => 2*i + 1) ++ List.tabulate(n/2)(i => 2*i + 2)
    }
    s"${solution.size}\n${solution mkString " "}"
  }
}

object A524 extends App{

 var k = readInt
 var str = new StringBuilder
 k
  match {
   case 1 | 2 => println(1); println(1)
   case 3 | 4 => println(2); println(1 + " " + 3)
   case 5 => println(5); println("1 4 2 5 3")
   case _ =>
     if (k % 2 == 0) {
       str.append(k + "\n")
       for (i <- 1 until k / 2 + 1)
         str.append(i + " " + (k/2 + i) + " ")
     }
     else {
       k -= 1
       str.append((k + 1) + "\n" + (k + 1) + " ")
       for (i <- 1 until k / 2 + 1)
         str.append(i + " " + (k/2 + i) + " ")
     }

     println(str.toString)
 }
}

import java.io._

object Main {

  val in = new BufferedReader(new InputStreamReader(System.in))
  val out = new PrintWriter(System.out)

  sys.addShutdownHook(out.close())

  @inline def nextInt = in.readLine().toInt
  @inline def nextInts = in.readLine().split(" +").map(_.toInt)
  @inline def println[T](x: T) = out.println(x)
  @inline def print[T](x: T) = out.print(x)

  def main(args: Array[String]): Unit = {
    val n = nextInt

    val used = collection.mutable.Set[Int](1)
    var ans: List[Int] = 1 :: Nil

    for (i ← 1 to n) {
      for (j ← 1 to n) {
        if (!(used contains j) && Math.abs(j - ans.head) > 1) {
          used += j
          ans = j :: ans
        }
      }
    }

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

import java.io._

object Main {

  val in = new BufferedReader(new InputStreamReader(System.in))
  val out = new PrintWriter(System.out)

  sys.addShutdownHook(out.close())

  @inline def nextInt = in.readLine().toInt
  @inline def nextInts = in.readLine().split(" +").map(_.toInt)
  @inline def println[T](x: T) = out.println(x)
  @inline def print[T](x: T) = out.print(x)

  def main(args: Array[String]): Unit = {
    val n = nextInt

    val used = collection.mutable.Set[Int](1)
    var ans: List[Int] = 1 :: Nil

    for (i ← 1 to n) {
      var done = false
      for (j ← 1 to n) {
        if (!done && !(used contains j) && Math.abs(j - ans.head) > 1) {
          used += j
          done = true
          ans = j :: ans
        }
      }
    }

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

/**
 * Author: Oleg Nizhnik
 * Date  : 14.04.2015
 * Time  : 16:01
 */
import scala.io.StdIn

object A extends App {
  val studs = StdIn.readInt() match {
    case 1 | 2 => Nil
    case 3 => List(1, 3)
    case 4 => List(3, 1, 4, 2)
    case n if n % 2 == 1 => 1 to 2 * n by 2 map (_ % n)
    case n => (1 to n by 2) ++ (2 to n by 2)
  }
  println(studs.length)
  println(studs mkString " ")
}

/**
 * Author: Oleg Nizhnik
 * Date  : 14.04.2015
 * Time  : 16:01
 */

import scala.io.StdIn

object A extends App {
  val studs = StdIn.readInt() match {
    case 1 => Nil
    case 2 => List(1)
    case 3 => List(1, 3)
    case 4 => List(3, 1, 4, 2)
    case n if n % 2 == 1 => 1 to 2 * n by 2 map (_ % n + 1)
    case n => (1 to n by 2) ++ (2 to n by 2)
  }
  println(studs.length)
  println(studs mkString " ")
}

/**
 * Author: Oleg Nizhnik
 * Date  : 14.04.2015
 * Time  : 16:01
 */
import scala.io.StdIn

object A extends App {
  val studs = StdIn.readInt() match {
    case 1 | 2 => Nil
    case 3 => List(1, 3)
    case 4 => List(3, 1, 4, 2)
    case n if n % 2 == 1 => 1 to 2 * n by 2 map (_ % n + 1)
    case n => (1 to n by 2) ++ (2 to n by 2)
  }
  println(studs.length)
  println(studs mkString " ")
}

/**
 *
 * Created by ronaflx on 15-4-3.
 */

import java.io._
import java.util.StringTokenizer;
import Ordering.Implicits._;

object Codeforces {
  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

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

  def nextInt: Int = {
    Integer.parseInt(next)
  }

  def nextLong: Long = {
    java.lang.Long.parseLong(next)
  }

  def upperBound[T: Ordering](array: Array[T], value: T) = {
    var low = 0
    var high = array.length
    var res = array.length
    while (low <= high) {
      val mid = (low + high) / 2
      if (value < array(mid)) {
        res = mid
        high = mid - 1
      } else {
        low = mid + 1
      }
    }
    res
  }

  def solve(): Unit = {
    val n = nextInt
    println(if (n <= 4) (n + 1) / 2 else n)
    for (i <- Range(1, n + 1, 2))
      print(i + " ")
    if (n > 4) for (i <- Range(2, n + 1, 2)) print(i + " ")
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}

/**
 *
 * Created by ronaflx on 15-4-3.
 */

import java.io._
import java.util.StringTokenizer;
import Ordering.Implicits._;

object Codeforces {
  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

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

  def nextInt: Int = {
    Integer.parseInt(next)
  }

  def nextLong: Long = {
    java.lang.Long.parseLong(next)
  }

  def upperBound[T: Ordering](array: Array[T], value: T) = {
    var low = 0
    var high = array.length
    var res = array.length
    while (low <= high) {
      val mid = (low + high) / 2
      if (value < array(mid)) {
        res = mid
        high = mid - 1
      } else {
        low = mid + 1
      }
    }
    res
  }

  def solve(): Unit = {
    val n = nextInt
    for (i <- Range(1, n + 1, 2))
      print(i + " ")
    if (n > 4) for (i <- Range(2, n + 1, 2)) print(i + " ")
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}

/**
 *
 * Created by ronaflx on 15-4-3.
 */

import java.io._
import java.util.StringTokenizer;
import Ordering.Implicits._;

object Codeforces {
  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

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

  def nextInt: Int = {
    Integer.parseInt(next)
  }

  def nextLong: Long = {
    java.lang.Long.parseLong(next)
  }

  def upperBound[T: Ordering](array: Array[T], value: T) = {
    var low = 0
    var high = array.length
    var res = array.length
    while (low <= high) {
      val mid = (low + high) / 2
      if (value < array(mid)) {
        res = mid
        high = mid - 1
      } else {
        low = mid + 1
      }
    }
    res
  }

  def solve(): Unit = {
    val n = nextInt
    println(if (n <= 4) n / 2 else n)
    for (i <- Range(1, n + 1, 2))
      print(i + " ")
    if (n > 4) for (i <- Range(2, n + 1, 2)) print(i + " ")
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}

object _534_A extends App {
  import java.util.Scanner

  import scala.collection.mutable

  lazy val file = getClass.getResourceAsStream(s"${getClass.getSimpleName.replace("$", "").last}.in")
  val in = if (submit) new Scanner(System.in) else new Scanner(file)

  while(in.hasNext) println(apply(parseInput))
  /******************************************************************************************************/
  def submit = true        // THIS MUST BE TRUE WHEN YOU SUBMIT !!!!

  type Input = Int

  def parseInput: Input = {
    import in._
    nextInt()
  }

  def apply(input: Input) = {
    val solution = input match {
      case 1 => List(1)
      case 2 => List(1)
      case 3 => List(1, 3)
      case 4 => List(1, 4, 2)
      case n => List.tabulate((n+1)/2)(i => 2*i + 1) ++ List.tabulate(n/2)(i => 2*i + 2)
    }
    s"${solution.size}\n${solution mkString " "}"
  }
}

object _534_A extends App {
  import java.util.Scanner

  import scala.collection.mutable

  lazy val file = getClass.getResourceAsStream(s"${getClass.getSimpleName.replace("$", "").last}.in")
  val in = if (submit) new Scanner(System.in) else new Scanner(file)

  while(in.hasNext) println(apply(parseInput))
  /******************************************************************************************************/
  def submit = true        // THIS MUST BE TRUE WHEN YOU SUBMIT !!!!

  type Input = Int

  def parseInput: Input = {
    import in._
    nextInt()
  }

  def apply(input: Input) = {
    val solution = input match {
      case 1 => List(1)
      case 2 => List(1)
      case 3 => List(1, 3)
      case 4 => List(1, 4, 2, 3)
      case n => List.tabulate((n+1)/2)(i => 2*i + 1) ++ List.tabulate(n/2)(i => 2*i + 2)
    }
    s"${solution.size}\n${solution mkString " "}"
  }
}