object B581 {

  import IO._

  def main(args: Array[String]): Unit = {
    val Array(n) = readInts(1)
    val in = readLongs(n)
    val max = Array.fill(n)(0L)
    for(i <- n-2 to 0 by -1) {
      max(i) = math.max(max(i+1), in(i+1))
    }
    println(max.zip(in).map{case (m, i) => math.max(0, m-i+1)}.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))
    }
  }

}

import java.io._

//581B
object B_LuxuriousHouses {

  def main(args: Array[String]): Unit = {
    val bis = new BufferedInputStream(System.in);
    val br = new BufferedReader(new InputStreamReader(bis));

    val n = Integer.parseInt(br.readLine())
    val arrStr = br.readLine().split(" ")
    val arr = arrStr.map { _.toInt}
    val lux = new Array[Int](arr.length)

    var max = 0
    for (i <- n-1 to 0 by -1) {
      if (arr(i) <= max) {
        lux(i) = max + 1 - arr(i)
      } else {
        lux(i) = 0
      }

      if (arr(i) > max) max = arr(i)
    }

    println(lux.mkString(" "))

  }
}

import scala.io.StdIn._
import scala.language.postfixOps

object TaskB extends App {
  readLine
  var maxH = 0
  val res = readLine.split(" ").map(_.toInt).reverse.map { a =>
    val r = math.max(maxH - a + 1, 0)
    maxH = math.max(maxH, a)
    r
  }.reverse.mkString(" ")
  println(res)
}

object EliteHouse {

  val in = io.Source.stdin.getLines()

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

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

  case class Pair(elements: List[Int], max: Int)

  def solve(houses: Seq[Int]): List[Int] =
    houses.foldRight(Pair(List.empty, 0)) { (currentElement, statusToTheRight) =>
      val maxToTheRight = currentElement max statusToTheRight.max
      val stairsToAdd = if (currentElement > statusToTheRight.max) 0 else statusToTheRight.max - currentElement + 1

      Pair(statusToTheRight.elements.+:(stairsToAdd), maxToTheRight)
    }.elements

  def main(args: Array[String]) {
    val Array(numberOfHouses) = readInts(1)
    val housesHeight = readInts(numberOfHouses)

    println(solve(housesHeight) mkString " ")
  }

}

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

import scala.collection.mutable

object B {

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

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

  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 java.lang.Long.parseLong(next)

  def nextDouble: Double = return java.lang.Double.parseDouble(next)

  class MultiHashSet[T <% Comparable[T]] {
    val map = new mutable.HashMap[T, Int]()

    def count(x: T): Int = {
      return map.getOrElse(x, 0)
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }
  }

  class MultiTreeSet[T <% Comparable[T]] {
    val map = new TreeMap[T, Int]()

    def count(x: T): Int = {
      val res = map.get(x)
      if (res == null)
        return 0
      return res
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def first(): T = return map.firstKey()

    def last(): T = return map.lastKey()

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }
  }

  /**
   * Segment tree for any commutative function
   * @param values Array of Int
   * @param commutative function like min, max, sum
   * @param zero zero value - e.g. 0 for sum, Inf for min, max
   */
  class SegmentTree(values: Array[Int])(commutative: (Int, Int) => Int)(zero: Int) {
    private val SIZE = 1e5.toInt
    private val n = values.length
    val t = new Array[Int](2 * n)
    Array.copy(values, 0, t, n, n)

    // build segment tree
    def build = {
      for (i <- n - 1 until 0 by -1) {
        t(i) = commutative(t(2 * i), t(2 * i + 1))
      }
    }

    // change value at position p to x
    // TODO beatify
    def modify(p: Int, x: Int) = {
      var pos = p + n
      t(pos) = x
      while (pos > 1) {
        t(pos / 2) = commutative(t(pos), t(pos ^ 1))
        pos /= 2
      }
    }

    // TODO implement me!
    def modify(p: Int, left: Int, right: Int) = ???

    def query(p: Int) = ???

    // sum [l, r)
    // min l = 0
    // max r = n
    // TODO beatify
    def query(left: Int, right: Int): Int = {
      var res = zero
      var r = right + n
      var l = left + n
      while (l < r) {
        if (l % 2 == 1) {
          res = commutative(res, t(l))
          l += 1
        }
        if (r % 2 == 1) {
          r -= 1
          res = commutative(res, t(r))
        }
        l /= 2
        r /= 2
      }
      res
    }
  }

  def solve: Int = {
    val n = nextInt
    val h = new Array[Int](n)
    for (i <- 0 until n) {
      h(i) = nextInt
    }
    val max = new Array[Int](n)
    max(n - 1) = h(n - 1)
    for (i <- n - 2 to 0 by -1) {
      max(i) = Math.max(max(i + 1), h(i))
    }
    for (i <- 0 until n - 1) {
      val m = max(i + 1)
      if (h(i) > m) {
        out.print(s"0 ")
      } else if (h(i) == m) {
        out.print(s"1 ")
      } else
        out.print((m - h(i) + 1) + " ")
    }
    out.print("0")
    return 0
  }
}

/**
 * @author netman
 */

import java.io._
import scala._
import scala.Array._
import scala.collection.mutable._
import java.util.StringTokenizer

object HelloWorld {

  class InputReader(reader: BufferedReader) {

    var tokenizer: StringTokenizer = null;

    def this(stream: InputStream) = {
      this(new BufferedReader(new InputStreamReader(stream), (1 << 20)));
    }

    def this(f: File) = {
      this(new BufferedReader(new FileReader(f), (1 << 20)));
    }

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

    def nextInt(): Int = next().toInt

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

    def close() = reader.close();
  }

  class OutputWriter(writer: PrintWriter) {
    def this(stream: OutputStream) {
      this(new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream))));
    }

    def this(f: File) = {
      this(new PrintWriter(new BufferedWriter(new FileWriter(f))));
    }

    def print(x: Any) = writer.print(x);

    def println(x: Any) = writer.println(x);

    def close() = writer.close();
  }

  val in = new InputReader(System.in)
  val out = new OutputWriter(System.out)

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

    val h = Array.fill[Int](n)(in.nextInt)
    var res = new Array[Int](n)

    var maximal = 0

    for (i <- n - 1 to 0 by -1) {
      res(i) = math.max(0, maximal - h(i) + 1)
      maximal = math.max(maximal, h(i))
    }

    for (i <- 0 to n - 1) {
      out.print(res(i) + " ")
    }
    out.println("")

    out.close
  }
}

object Sol {
  import scala.io.StdIn._
  import scala.collection.mutable._

  def main(args: Array[String]) {
    val n = readInt()
    val arr = readLine().split(" ").map(_.toInt)

    val ab = ArrayBuffer[Int]()
    var largest = scala.Int.MinValue

    for (i <- (0 until arr.length).reverse) {
      if (largest < arr(i)) {
        ab += 0
        largest = arr(i)
      } else {
        ab += largest - arr(i) + 1
      }
    }

    println(ab.reverse.mkString(" "))
  }
}

object Sol {
  import scala.io.StdIn._
  import scala.collection.mutable._

  def main(args: Array[String]) {
    val n = readInt()
    val arr = readLine().split(" ").map(_.toInt)

    var ab = Array.fill(n)(0)
    var largest = scala.Int.MinValue

    for (i <- (0 until arr.length).reverse) {
      if (largest < arr(i)) {
        ab(i) = 0
        largest = arr(i)
      } else {
        ab(i) = largest - arr(i) + 1
      }
    }

    println(ab.mkString(" "))
  }
}

import scala.io.StdIn._

object B extends App {
  readLine()
  val A = readLine().split(" ").map(_.toLong)
  val Max = Array.ofDim[Long](A.length)
  val map = new scala.collection.mutable.HashMap[Long, Boolean]()

  var max = A.last
  for (i <- A.length - 1 to 0 by - 1) {
    Max(i) = Math.max(max, A(i))
    max = Max(i)
  }

//  println(Max.mkString(" "))
  println(A.zip(Max).reverse.map{ case (curr, max) =>
//    println(a + " " + b)
    if (max > curr) {
      max - curr + 1
    }
    else {
      val add = map.getOrElse(curr, false)
      map.put(curr, true)
      if (add) 1 else 0
    }
  }.reverse.mkString(" "))

}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val n = in.next().toInt
  val data = in.next().split(" ").map(_.toInt)
  val max = data.reverse.scanLeft(0){Math.max}.init.reverse
  val res = data.zip(max).map{
    case(now, max) => Math.max(0, max - now + 1)
  }
  println(res.mkString(" "))
}

import java.util.Scanner
import java.io.BufferedInputStream

object Main extends App {
  implicit val scanner = new Scanner(new BufferedInputStream(System.in))
  def nextInt(implicit in: Scanner) = in.nextInt
  def nextLong(implicit in: Scanner) = in.nextLong

  // main start

  val n = nextInt
  val hs = Array.fill(n)(nextInt)
  var hmax = 0
  for (i <- 1 to n) {
    if (hmax >= hs(n-i)) {
      hs(n-i) = hmax-hs(n-i)+1
    } else {
      hmax = hs(n-i)
      hs(n-i) = 0
    }
  }
  println(hs mkString " ")
}

//Main.main(args)

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

import scala.collection.mutable

object B {

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

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

  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 java.lang.Long.parseLong(next)

  def nextDouble: Double = return java.lang.Double.parseDouble(next)

  class MultiHashSet[T <% Comparable[T]] {
    val map = new mutable.HashMap[T, Int]()

    def count(x: T): Int = {
      return map.getOrElse(x, 0)
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }
  }

  class MultiTreeSet[T <% Comparable[T]] {
    val map = new TreeMap[T, Int]()

    def count(x: T): Int = {
      val res = map.get(x)
      if (res == null)
        return 0
      return res
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def first(): T = return map.firstKey()

    def last(): T = return map.lastKey()

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }
  }

  /**
   * Segment tree for any commutative function
   * @param values Array of Int
   * @param commutative function like min, max, sum
   * @param zero zero value - e.g. 0 for sum, Inf for min, max
   */
  class SegmentTree(values: Array[Int])(commutative: (Int, Int) => Int)(zero: Int) {
    private val SIZE = 1e5.toInt
    private val n = values.length
    val t = new Array[Int](2 * n)
    Array.copy(values, 0, t, n, n)

    // build segment tree
    def build = {
      for (i <- n - 1 until 0 by -1) {
        t(i) = commutative(t(2 * i), t(2 * i + 1))
      }
    }

    // change value at position p to x
    // TODO beatify
    def modify(p: Int, x: Int) = {
      var pos = p + n
      t(pos) = x
      while (pos > 1) {
        t(pos / 2) = commutative(t(pos), t(pos ^ 1))
        pos /= 2
      }
    }

    // TODO implement me!
    def modify(p: Int, left: Int, right: Int) = ???

    def query(p: Int) = ???

    // sum [l, r)
    // min l = 0
    // max r = n
    // TODO beatify
    def query(left: Int, right: Int): Int = {
      var res = zero
      var r = right + n
      var l = left + n
      while (l < r) {
        if (l % 2 == 1) {
          res = commutative(res, t(l))
          l += 1
        }
        if (r % 2 == 1) {
          r -= 1
          res = commutative(res, t(r))
        }
        l /= 2
        r /= 2
      }
      res
    }
  }

  def solve: Int = {
    val n = nextInt
    val h = new Array[Int](n)
    for (i <- 0 until n) {
      h(i) = nextInt
    }
    val max = new Array[Int](n)
    max(n - 1) = h(n - 1)
    for (i <- n - 2 to 0 by -1) {
      max(i) = Math.max(max(i + 1), h(i))
    }
    for (i <- 0 until n - 1) {
      val m = max(i)
      if (h(i) > max(i)) {
        out.print(s"0 ")
      } else
        out.print((max(i) - h(i) + 1) + " ")
    }
    out.print("0")
    return 0
  }
}

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

import scala.collection.mutable

object B {

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

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

  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 java.lang.Long.parseLong(next)

  def nextDouble: Double = return java.lang.Double.parseDouble(next)

  class MultiHashSet[T <% Comparable[T]] {
    val map = new mutable.HashMap[T, Int]()

    def count(x: T): Int = {
      return map.getOrElse(x, 0)
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }
  }

  class MultiTreeSet[T <% Comparable[T]] {
    val map = new TreeMap[T, Int]()

    def count(x: T): Int = {
      val res = map.get(x)
      if (res == null)
        return 0
      return res
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def first(): T = return map.firstKey()

    def last(): T = return map.lastKey()

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }
  }

  /**
   * Segment tree for any commutative function
   * @param values Array of Int
   * @param commutative function like min, max, sum
   * @param zero zero value - e.g. 0 for sum, Inf for min, max
   */
  class SegmentTree(values: Array[Int])(commutative: (Int, Int) => Int)(zero: Int) {
    private val SIZE = 1e5.toInt
    private val n = values.length
    val t = new Array[Int](2 * n)
    Array.copy(values, 0, t, n, n)

    // build segment tree
    def build = {
      for (i <- n - 1 until 0 by -1) {
        t(i) = commutative(t(2 * i), t(2 * i + 1))
      }
    }

    // change value at position p to x
    // TODO beatify
    def modify(p: Int, x: Int) = {
      var pos = p + n
      t(pos) = x
      while (pos > 1) {
        t(pos / 2) = commutative(t(pos), t(pos ^ 1))
        pos /= 2
      }
    }

    // TODO implement me!
    def modify(p: Int, left: Int, right: Int) = ???

    def query(p: Int) = ???

    // sum [l, r)
    // min l = 0
    // max r = n
    // TODO beatify
    def query(left: Int, right: Int): Int = {
      var res = zero
      var r = right + n
      var l = left + n
      while (l < r) {
        if (l % 2 == 1) {
          res = commutative(res, t(l))
          l += 1
        }
        if (r % 2 == 1) {
          r -= 1
          res = commutative(res, t(r))
        }
        l /= 2
        r /= 2
      }
      res
    }
  }

  def solve: Int = {
    val n = nextInt
    val h = new Array[Int](n)
    for (i <- 0 until n) {
      h(i) = nextInt
    }
    val max = new Array[Int](n)
    max(n - 1) = h(n - 1)
    for (i <- n - 2 to 0 by -1) {
      max(i) = Math.max(max(i + 1), h(i))
    }
    for (i <- 0 until n - 1) {
      val m = max(i)
      if (h(i) >= max(i)) {
        out.print(s"0 ")
      } else
        out.print((max(i) - h(i) + 1) + " ")
    }
    out.print("0")
    return 0
  }
}

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

import scala.collection.mutable

object B {

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

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

  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 java.lang.Long.parseLong(next)

  def nextDouble: Double = return java.lang.Double.parseDouble(next)

  class MultiHashSet[T <% Comparable[T]] {
    val map = new mutable.HashMap[T, Int]()

    def count(x: T): Int = {
      return map.getOrElse(x, 0)
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }
  }

  class MultiTreeSet[T <% Comparable[T]] {
    val map = new TreeMap[T, Int]()

    def count(x: T): Int = {
      val res = map.get(x)
      if (res == null)
        return 0
      return res
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def first(): T = return map.firstKey()

    def last(): T = return map.lastKey()

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }
  }

  /**
   * Segment tree for any commutative function
   * @param values Array of Int
   * @param commutative function like min, max, sum
   * @param zero zero value - e.g. 0 for sum, Inf for min, max
   */
  class SegmentTree(values: Array[Int])(commutative: (Int, Int) => Int)(zero: Int) {
    private val SIZE = 1e5.toInt
    private val n = values.length
    val t = new Array[Int](2 * n)
    Array.copy(values, 0, t, n, n)

    // build segment tree
    def build = {
      for (i <- n - 1 until 0 by -1) {
        t(i) = commutative(t(2 * i), t(2 * i + 1))
      }
    }

    // change value at position p to x
    // TODO beatify
    def modify(p: Int, x: Int) = {
      var pos = p + n
      t(pos) = x
      while (pos > 1) {
        t(pos / 2) = commutative(t(pos), t(pos ^ 1))
        pos /= 2
      }
    }

    // TODO implement me!
    def modify(p: Int, left: Int, right: Int) = ???

    def query(p: Int) = ???

    // sum [l, r)
    // min l = 0
    // max r = n
    // TODO beatify
    def query(left: Int, right: Int): Int = {
      var res = zero
      var r = right + n
      var l = left + n
      while (l < r) {
        if (l % 2 == 1) {
          res = commutative(res, t(l))
          l += 1
        }
        if (r % 2 == 1) {
          r -= 1
          res = commutative(res, t(r))
        }
        l /= 2
        r /= 2
      }
      res
    }
  }

  def solve: Int = {
    val n = nextInt
    val h = new Array[Int](n)
    for (i <- 0 until n) {
      h(i) = nextInt
    }
    val max = new Array[Int](n)
    max(n - 1) = h(n - 1)
    for (i <- n - 2 to 0 by -1) {
      max(i) = Math.max(max(i + 1), h(i))
    }
    for (i <- 0 until n - 1) {
      val m = max(i + 1)
      if (h(i) < max(i + 1)) {
        out.print((max(i + 1) - h(i) + 1) + " ")
      } else {
        out.print(0 + " ")
      }
    }
    out.print("0")
    return 0
  }
}

import scala.io.StdIn._

object B extends App {
  readLine()
  val A = readLine().split(" ").map(_.toLong)
  val Max = Array.ofDim[Long](A.length)
  val map = new scala.collection.mutable.HashMap[Long, Int]()

  var max = A.last
  for (i <- A.length - 1 to 0 by - 1) {
    Max(i) = Math.max(max, A(i))
    max = Max(i)
  }

//  println(Max.mkString(" "))
  println(A.zip(Max).reverse.map{ case (curr, max) =>
//    println(a + " " + b)
    if (max > curr) {
      max - curr + 1
    }
    else {
      val add = map.getOrElse(curr, 0)
      map.put(curr, add + 1)
      add
    }
  }.reverse.mkString(" "))

}

import scala.io.StdIn._

object B extends App {
  readLine()
  val A = readLine().split(" ").map(_.toLong)
  val Max = Array.ofDim[Long](A.length)

  var max = A.last
  for (i <- A.length - 1 to 0 by - 1) {
    Max(i) = Math.max(max, A(i))
    max = Max(i)
  }

//  println(Max.mkString(" "))
  println(A.zip(Max).map { case (a, b) =>
//    println(a + " " + b)
    if (b > a) b - a + 1
    else 0
  } mkString " ")

}

import java.util.Scanner
import java.io.BufferedInputStream

object Main extends App {
  implicit val scanner = new Scanner(new BufferedInputStream(System.in))
  def nextInt(implicit in: Scanner) = in.nextInt
  def nextLong(implicit in: Scanner) = in.nextLong

  // main start

  val n = nextInt
  val hs = Array.fill(n)(nextInt)
  var hmax = hs.last
  for (i <- 1 to n) {
    if (hmax >= hs(n-i)) {
      hs(n-i) = hmax-hs(n-i)+1
    } else {
      hmax = hs(n-i)
      hs(n-i) = 0
    }
  }
  println(hs mkString " ")
}

//Main.main(args)

import java.util.Scanner
import java.io.BufferedInputStream

object Main extends App {
  implicit val scanner = new Scanner(new BufferedInputStream(System.in))
  def nextInt(implicit in: Scanner) = in.nextInt
  def nextLong(implicit in: Scanner) = in.nextLong

  // main start

  val n = nextInt
  val hs = Array.fill(n)(nextInt)
  var hmax = hs.last
  for (i <- 1 to n) {
    val h = hs(n-i)
    hs(n-i) = hmax-h+1
    hmax = if (hmax>h) hmax else h
  }
  println(hs mkString " ")
}

//Main.main(args)

import java.util.Scanner
import java.io.BufferedInputStream

object Main extends App {
  implicit val scanner = new Scanner(new BufferedInputStream(System.in))
  def nextInt(implicit in: Scanner) = in.nextInt
  def nextLong(implicit in: Scanner) = in.nextLong

  // main start

  val n = nextInt
  val hs = Array.fill(n)(nextInt)
  var hmax = hs.last
  for (i <- 1 to n) {
    if (hmax > hs(n-i)) {
      hs(n-i) = hmax-hs(n-i)+1
    } else {
      hmax = hs(n-i)
      hs(n-i) = 0
    }
  }
  println(hs mkString " ")
}

//Main.main(args)

import java.util.Scanner
import java.io.BufferedInputStream

object Main extends App {
  implicit val scanner = new Scanner(new BufferedInputStream(System.in))
  def nextInt(implicit in: Scanner) = in.nextInt
  def nextLong(implicit in: Scanner) = in.nextLong

  // main start

  val n = nextInt
  val hs = Array.fill(n)(nextInt)
  var hmax = hs.last
  for (i <- 1 to n) {
    val h = hs(n-i)
    hs(n-i) = hmax-h+1
    hmax = if (hmax>h) hmax else h
  }
  println(hs.mkString)
}

object Sol {
  import scala.io.StdIn._
  import scala.collection.mutable._

  def main(args: Array[String]) {
    val n = readInt()
    val arr = readLine().split(" ").map(_.toInt)

    val ab = ArrayBuffer[Int]()
    var largest = scala.Int.MinValue

    for (i <- (0 until arr.length).reverse) {
      if (largest <= arr(i)) {
        ab += 0
        largest = arr(i)
      } else {
        ab += largest - arr(i) + 1
      }
    }

    println(ab.reverse.mkString(" "))
  }
}

object Sol {
  import scala.io.StdIn._
  import scala.collection.mutable._

  def main(args: Array[String]) {
    val n = readInt()
    val arr = readLine().split(" ").map(_.toInt)

    val ab = ArrayBuffer[Int]()
    var largest = scala.Int.MinValue

    for (i <- (0 until arr.length).reverse) {
      if (largest <= arr(i)) {
        ab += 0
        largest = arr(i)
      } else {
        ab += largest - arr(i) + 1
      }
    }

    println(ab.reverse)
  }
}


object B544{
  def main(args: Array[String]){
    var Array(n,k) = readLine.split(" ").map(_.toInt)
    if((n*n+1)/2<k){
      println("NO")
    }
    else {
      println("YES")
      for(i <- 0 to n-1){
        if(i%2==0){
          for(j <- 0 to n-1){
            if(j%2==0&&k>0){
              k=k-1
              print("L")
            }
            else {
              print("S")
            }
          }
        }
        else {
          for(j <- 0 to n-1){
            if(j%2==1&&k>0){
              k=k-1
              print("L")
            }
            else {
              print("S")
            }
          }
        }
        println("")
      }
    }

  }
}

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

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

import scala.Ordering.Implicits._
import scala.collection.mutable.ArrayBuffer

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 lowerBound[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 (!(array(mid) < value)) {
        res = mid
        high = mid - 1
      } else {
        low = mid + 1
      }
    }
    res
  }

  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
  }

  val N = 210001;
  val bit: Array[Int] = new Array[Int](N)

  def addBit(pos: Int, value: Int): Unit = {
    var i = pos
    while (i < N) {
      bit(i) += value
      i += (i & (i ^ (i - 1)))
    }
  }

  def getBit(pos: Int): Int = {
    var (i, res) = (pos, 0)
    while (i > 0) {
      res += bit(i)
      i -= (i & (i ^ (i - 1)))
    }
    return res
  }

  def getRange(from: Int, to: Int): Int = {
    return getBit(to) - getBit(from - 1)
  }

  def solve(): Unit = {
    val (n, m) = (nextInt, nextInt)
    val map = Array.ofDim[Char](n, n)
    if ((n * n + 1) / 2 < m) {
      out.println("NO")
    } else {
      out.println("YES")
      var num_land = 0
      for (i <- 0 until n; j <- 0 until n) {
        if (num_land < m && (n & 1) != ((i + j) & 1)) {
          num_land += 1
          map(i)(j) = 'L'
        } else {
          map(i)(j) = 'S'
        }
      }
      map.foreach(line => out.println(line.mkString("")))
    }
  }

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

object B544 extends App {
  import java.util.Scanner
  def apply(problem: String): String = apply(new Scanner(problem))
  def apply(scanner: Scanner): String = format(solve(read(scanner)))
  println(apply(new Scanner(System.in)))
  /***************************************************************************/
  type Input = (Int, Int)

  type Output = Option[List[String]]

  def read(scanner: Scanner): Input = {
    import scanner._
    (nextInt, nextInt)
  }

  def solve(input: Input): Output = {
    val (n, k) = input
    if (k > ((n*n) + 1)/2) {
      None
    } else {
      var tk = k
      val sol = List.tabulate(n, n) {(r, c) =>
        (r%2, c%2) match {
          case (m1, m2) if m1 == m2 && tk > 0 =>
            tk = tk - 1
            'L'
          case _ => 'S'
        }
      }
      Some (sol map {_.mkString})
    }
  }

  def format(result: Output): String = result match {
    case Some(sol) => ("YES" :: sol).mkString("\n")
    case None => "NO"
  }
}

import scala.io.StdIn._

import Math.min

/**
 * Created by slie742 on 18/09/2015.
 */
object SeaAndIslands {

  def readInts() : Array[Int] =
    readLine.split(' ').map(_.toInt)

  def readTuple() : (Int,Int) = {
    val line = readInts
    (line(0),line(1))
  }

  def getIsland(n: Int, k: Int) : Option[List[String]] = {
    def go(lineNr: Int, islands: Int, acc: List[String]) : Option[List[String]] = {
      if (lineNr >= n) {
        if (islands == 0) Some(acc) else None
      } else {
        if (islands == 0) {
          go(lineNr + 1, islands, ("S"*n) :: acc)
        } else {
          if (lineNr % 2 == 0) {
            if (islands >= (n+1)/2) { // full line
              val line = "LS"*(n/2) + (if (n%2 == 0) "" else "L")
              go(lineNr+1, islands - (n+1)/2, line :: acc)
            } else {
              val line = "LS"*islands + "S"*(n-2*islands)
              go(lineNr+1, 0, line :: acc)
            }
          } else { // odd Line
            if (islands >= n/2) { // full line
              val line = "SL"*(n/2) + (if (n%2 == 0) "" else "S")
              go(lineNr+1, islands - n/2, line :: acc)
            } else {
              val line = "SL"*islands + "S"*(n-2*islands)
              go(lineNr+1, 0, line :: acc)
            }
          }
        }
      }
    }
    go(0, k, Nil)
  }

  def main(args: Array[String]) {
    val (n,k) = readTuple()

    getIsland(n,k) match {
      case Some(list) =>
        println("YES")
        println(list.mkString("\n"))
      case None       => println("NO")
    }
  }
}

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

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

import scala.Ordering.Implicits._
import scala.collection.mutable.ArrayBuffer

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 lowerBound[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 (!(array(mid) < value)) {
        res = mid
        high = mid - 1
      } else {
        low = mid + 1
      }
    }
    res
  }

  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
  }

  val N = 210001;
  val bit: Array[Int] = new Array[Int](N)

  def addBit(pos: Int, value: Int): Unit = {
    var i = pos
    while (i < N) {
      bit(i) += value
      i += (i & (i ^ (i - 1)))
    }
  }

  def getBit(pos: Int): Int = {
    var (i, res) = (pos, 0)
    while (i > 0) {
      res += bit(i)
      i -= (i & (i ^ (i - 1)))
    }
    return res
  }

  def getRange(from: Int, to: Int): Int = {
    return getBit(to) - getBit(from - 1)
  }

  def solve(): Unit = {
    val (n, m) = (nextInt, nextInt)
    val map = Array.ofDim[Char](n, n)
    if ((n + 1) / 2 < m) {
      out.println("NO")
    } else {
      out.println("YES")
      var num_land = 0
      for (i <- 0 until n; j <- 0 until n) {
        if (num_land < m && (n & 1) == ((i + j) & 1)) {
          num_land += 1
          map(i)(j) = 'L'
        } else {
          map(i)(j) = 'S'
        }
      }
      map.foreach(line => out.println(line.mkString("")))
    }
  }

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

object B544 extends App {
  /********************************[ I/O ]************************************/
  import java.util.Scanner
  val isOnlineJudge = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  //import com.softwaremill.debug.DebugConsole.debug
  def debug(x: Any) = if (!isOnlineJudge) println(x)
  def apply(problem: String): String = apply(new Scanner(problem))
  def apply(scanner: Scanner): String = format(solve(read(scanner)))
  println(apply(new Scanner(System.in)))
  /********************************[ lib ]************************************/
  import scala.collection.mutable
  case class Memo[I, K, O](f: I => O)(implicit encoder: I => K) extends (I => O) {
    val cache = mutable.Map.empty[K, O]
    override def apply(x: I): O = cache.getOrElseUpdate(x, f(x))
  }
  type m_=>[I, O] = Memo[I, I, O]
  /******************************[ solution ]*********************************/
  type Input = (Int, Int)

  type Output = List[String]

  def read(scanner: Scanner): Input = {
    import scanner._
    (nextInt, nextInt)
  }

  def solve(input: Input): Output = {
    val (n, k) = input
    if (k >= (n*n + 1)/2) {
      List("NO")
    } else {
      var tk = k
      val sol = List.tabulate(n, n) {(r, c) =>
        (r%2, c%2) match {
          case (m1, m2) if m1 == m2 && tk > 0 => tk -= 1; 'L'
          case _ => 'S'
        }
      }
      "YES" :: (sol map {_.mkString})
    }
  }

  def format(result: Output): String = result mkString "\n"
}

import scala.io.StdIn._

import Math.min

/**
 * Created by slie742 on 18/09/2015.
 */
object SeaAndIslands {

  def readInts() : Array[Int] =
    readLine.split(' ').map(_.toInt)

  def readTuple() : (Int,Int) = {
    val line = readInts
    (line(0),line(1))
  }

  def getIsland(n: Int, k: Int) : Option[List[String]] = {
    def go(lineNr: Int, islands: Int, acc: List[String]) : Option[List[String]] = {
      if (lineNr >= n) {
        if (islands == 0) Some(acc) else None
      } else {
        if (islands == 0) {
          go(lineNr + 1, islands, ("S"*n) :: acc)
        } else {
          if (lineNr % 2 == 0) {
            if (islands >= (n+1)/2) { // full line
              val line = "LS"*(n/2) + (if (n%2 == 0) "" else "L")
              go(lineNr+1, islands - (n+1)/2, line :: acc)
            } else {
              val line = "LS"*islands + "S"*(n-2*islands)
              go(lineNr+1, 0, line :: acc)
            }
          } else { // odd Line
            if (islands >= n/2) { // full line
              val line = "SL"*(n/2) + (if (n%2 == 0) "" else "S")
              go(lineNr+1, islands - n/2, line :: acc)
            } else {
              val line = "SL"*islands + "S"*(n-2*islands)
              go(lineNr+1, 0, line :: acc)
            }
          }
        }
      }
    }
    go(0, k, Nil)
  }

  def main(args: Array[String]) {
    val (n,k) = readTuple()

    getIsland(n,k) match {
      case Some(list) => println(list.mkString("\n"))
      case None       => println("No")
    }
  }
}

import scala.io.StdIn._

import Math.min

/**
 * Created by slie742 on 18/09/2015.
 */
object SeaAndIslands {

  def readInts() : Array[Int] =
    readLine.split(' ').map(_.toInt)

  def readTuple() : (Int,Int) = {
    val line = readInts
    (line(0),line(1))
  }

  def getIsland(n: Int, k: Int) : Option[List[String]] = {
    def go(lineNr: Int, islands: Int, acc: List[String]) : Option[List[String]] = {
      if (lineNr >= n) {
        if (islands == 0) Some(acc) else None
      } else {
        if (islands == 0) {
          go(lineNr + 1, islands, ("S"*n) :: acc)
        } else {
          if (lineNr % 2 == 0) {
            if (islands >= (n+1)/2) { // full line
              val line = "LS"*(n/2) + (if (n%2 == 0) "" else "L")
              go(lineNr+1, islands - (n+1)/2, line :: acc)
            } else {
              val line = "LS"*islands + "S"*(n-2*islands)
              go(lineNr+1, 0, line :: acc)
            }
          } else { // odd Line
            if (islands >= n/2) { // full line
              val line = "SL"*(n/2) + (if (n%2 == 0) "" else "S")
              go(lineNr+1, islands - n/2, line :: acc)
            } else {
              val line = "SL"*islands + "S"*(n-2*islands)
              go(lineNr+1, 0, line :: acc)
            }
          }
        }
      }
    }
    go(0, k, Nil)
  }

  def main(args: Array[String]) {
    val (n,k) = readTuple()

    getIsland(n,k) match {
      case Some(list) =>
        println("YES")
        println(list.mkString("\n"))
      case None       => println("No")
    }
  }
}

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

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

import scala.Ordering.Implicits._
import scala.collection.mutable.ArrayBuffer

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 lowerBound[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 (!(array(mid) < value)) {
        res = mid
        high = mid - 1
      } else {
        low = mid + 1
      }
    }
    res
  }

  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
  }

  val N = 210001;
  val bit: Array[Int] = new Array[Int](N)

  def addBit(pos: Int, value: Int): Unit = {
    var i = pos
    while (i < N) {
      bit(i) += value
      i += (i & (i ^ (i - 1)))
    }
  }

  def getBit(pos: Int): Int = {
    var (i, res) = (pos, 0)
    while (i > 0) {
      res += bit(i)
      i -= (i & (i ^ (i - 1)))
    }
    return res
  }

  def getRange(from: Int, to: Int): Int = {
    return getBit(to) - getBit(from - 1)
  }

  def solve(): Unit = {
    val (n, m) = (nextInt, nextInt)
    val map = Array.ofDim[Char](n, n)
    if ((n + 1) / 2 < m) {
      out.println("NO")
    } else {
      out.println("YES")
      var num_land = 0
      for (i <- 0 until n; j <- 0 until n) {
        if (num_land < m && (n & 1) == ((i + j) & 1)) {
          num_land += 1
          map(i)(j) = 'L'
        } else {
          map(i)(j) = 'S'
        }
      }
      map.foreach(line => println(line.mkString("")))
    }
  }

  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 scala.Ordering.Implicits._
import scala.collection.mutable.ArrayBuffer

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 lowerBound[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 (!(array(mid) < value)) {
        res = mid
        high = mid - 1
      } else {
        low = mid + 1
      }
    }
    res
  }

  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
  }

  val N = 210001;
  val bit: Array[Int] = new Array[Int](N)

  def addBit(pos: Int, value: Int): Unit = {
    var i = pos
    while (i < N) {
      bit(i) += value
      i += (i & (i ^ (i - 1)))
    }
  }

  def getBit(pos: Int): Int = {
    var (i, res) = (pos, 0)
    while (i > 0) {
      res += bit(i)
      i -= (i & (i ^ (i - 1)))
    }
    return res
  }

  def getRange(from: Int, to: Int): Int = {
    return getBit(to) - getBit(from - 1)
  }

  def solve(): Unit = {
    val (n, m) = (nextInt, nextInt)
    val map = Array.ofDim[Char](n, n)
    if ((n * n + 1) / 2 < m) {
      out.println("NO")
    } else {
      out.println("YES")
      var num_land = 0
      for (i <- 0 until n; j <- 0 until n) {
        if (num_land < m && (n & 1) == ((i + j) & 1)) {
          num_land += 1
          map(i)(j) = 'L'
        } else {
          map(i)(j) = 'S'
        }
      }
      map.foreach(line => out.println(line.mkString("")))
    }
  }

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


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

  override def solve(io: IO) = io.repeat {
    val p = io.read[String].sorted
    val h = io.read[String]
    val ans = h.sliding(p.length).exists(_.sorted == p)
    io.write(ans.toEnglish.toUpperCase)
  }
}
/****************************[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 solve(io: IO): Any
  def main(args: Array[String]): Unit = {
    val io = new IO(System.in, System.out)
    try solve(io) finally io.close()
  }
}
/****************************[Scala Collection Utils]****************************************/
object Utils {
  import scala.collection.mutable

  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]

  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)

  implicit class GenericExtensions[A](a: A) {
    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a
  }

  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](t: C[A]) {
    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]

    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)

    def toMultiSet(withDefaultZero: Boolean): Map[A, Int] = {
      val freqTable = t.groupBy(identity).mapValues(_.size)
      if (withDefaultZero) freqTable.withDefaultValue(0) else freqTable
    }
  }

  implicit class PairExtensions[A, B](p: (A, B)) {
    def key = p._1
    def value = p._2
    def toSeq(implicit ev: B =:= A): Seq[A] = Seq(p.key, ev(p.value))
  }

  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {
    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_.key).mapValues(_.map(_.value).to[C]).withDefaultValue(b().result())
  }

  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](m: C[K, V]) {
    def toMutable: mutable.Map[K, V] = mutable.Map.empty[K, V] ++ m
  }

  implicit class SetExtensions[A, C[A] <: Set[A]](s: C[A]) {
    def notContains(x: A): Boolean = !(s contains x)
    def toMutable = mutable.Set.empty[A] ++ s
  }

  implicit class IterableExtensions[A, C[A] <: Seq[A]](s: C[A]) {
    def indicesWhere(f: A => Boolean): Seq[Int] = s.zipWithIndex.collect {case (a, i) if f(a) => i}
    def deleteAtIndex(i: Int, howMany: Int = 1) = s.patch(i, Nil, howMany)
    def insertAtIndex(i: Int, items: Seq[A]) = s.patch(i, items, 0)
    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}
  }

  implicit class BooleanExtensions(x: Boolean) {
    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero
    def toEnglish = if(x) "Yes" else "No"
  }

  implicit class IntExtensions(val x: Int) extends AnyVal {
    @inline def isEven = x%2 == 0
    @inline def isOdd = x%2 == 1
  }

  def desc[A](implicit order: Ordering[A]): Ordering[A] = order.reverse  //e.g. students.sortBy(_.height)(desc)

  def map[K] = new {
    def to[V](default: => V): mutable.Map[K, V] = using(_ => default)
    def using[V](f: K => V): mutable.Map[K, V] = new mutable.HashMap[K, V]() {
      override def apply(key: K) = getOrElseUpdate(key, f(key))
    }
  }

  def newMultiMap[K, V] = map[K] to mutable.Set.empty[V]

  def memoize[A, B](f: A => B): A => B = map[A] using f
}
/***********************************[Scala I/O]*********************************************/
import java.io._, java.util.StringTokenizer
import scala.collection.generic.CanBuild

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

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

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

  def read[A](implicit read: IO.Read[A]): A = read.apply(this)
  def read[C[_], A: IO.Read](n: Int)(implicit b: CanBuild[A, C[A]]): C[A] = Iterator.fill(n)(read).to[C]
  def readTill(delim: String): String = tokenizer().get.nextToken(delim)
  def readTillEndOfLine(): String = readTill("\n\r")

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

  def write(obj: Any*): this.type = writeAll(obj)
  def writeLine(obj: Any*): this.type = {if (obj.isEmpty) printer.println() else obj.foreach(printer.println); this}
  def writeAll(obj: Traversable[Any], separator: String = " "): this.type = {printer.print(obj.mkString(separator)); this}
  def query[A: IO.Read](question: Any): A = writeLine(question).read

  def repeat(f: => Unit): Unit = Utils.repeat(read[Int]){f; writeLine()}

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

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

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

  private[this] val oj = System.getenv("ATCODER_DEBUG") == null
  def DEBUG(f: => Unit): Unit = {
    if (!oj){ f }
  }
  def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) "1" else "0").mkString) }
  def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(" ")) }
  def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(" ")) }
  def debugDim(m: Array[Array[Int]]): Unit = if (!oj){
    REP(m.length) { i =>
      debug(m(i))
    }
  }
  def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){
    REP(m(0).length) { j =>
      REP(m.length) { i =>
        System.err.print(m(i)(j))
        System.err.print(" ")
      }
      System.err.println()
    }
  }
  def debug(s: => String): Unit = {
    if (oj){ System.err.println(s) }
  }
  def isDebug[A](debug: => A, online: => A): A = {
    if (oj) online else debug
  }

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

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

    def nextInt(): Int = Integer.parseInt(next())
    def nextLong(): Long = java.lang.Long.parseLong(next())
    def nextChar(): Char = next().charAt(0)

    def ni(): Int = nextInt()
    def nl(): Long = nextLong()
    def nc(): Char = nextChar()
    def ns(): String = next()
    def ns(n: Int): Array[Char] = ns().toCharArray
    def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
    def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
      val A1, A2 = Array.ofDim[Int](n)
      REP(n) { i =>
        A1(i) = ni() + offset
        A2(i) = ni() + offset
      }
      (A1, A2)
    }
    def nm(n: Int, m: Int): Array[Array[Int]] = {
      val A = Array.ofDim[Int](n, m)
      REP(n) { i =>
        REP(m) { j =>
          A(i)(j) = ni()
        }
      }
      A
    }
    def nal(n: Int): Array[Long] = map(n)(_ => nl())
    def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  }

  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }
  def TO(from: Int, to: Int)(f: Int => Unit): Unit = {
    REP(to - from + 1, from)(f)
  }
  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }

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

object Workspace {
  import Main._
  import java.util.Arrays.sort

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

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

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

  // toIntとか+7とかするならvalにしろ
  final private[this] val MOD = 1000000007

  def solve2(): Boolean = {
    val P, H = ns()
    if (P.length > H.length) return false

    val C = Array.ofDim[Int](26)
    REP(P.length) { i =>
      C(P(i)-'a') += 1
    }

    REP(H.length - P.length + 1) { i =>
      val D = Array.ofDim[Int](26)
      REP(P.length) { j =>
        D(H(i + j)-'a') += 1
      }
      var ok = true
      REP(26) { c =>
        ok &&= C(c) == D(c)
      }
      if (ok) return true
    }
    false
  }

  def solve(): Unit = {
    REP(ni()) { _ =>
      if (solve2()) {
        out.println("YES")
      } else {
        out.println("NO")
      }
    }
  }
}


object Main {
  def main(args: Array[String]): Unit = {
    val ynk = readLine().split(" ").map(_.toInt)
    val y = ynk(0)
    val n = ynk(2)
    val k = ynk(1)

    val start =
      if (k == 1) y + 1
      else (y / k + 1) * k
    if (start > n) println("-1")
    else println( (start to n by k).map(_ - y).mkString(" ") )
  }
}

import java.io.InputStreamReader
import java.io.BufferedReader

object Main extends App {
  val Array(y, k, n) = readLine().split(' ').map(Integer.parseInt(_))
  var ost = k - (y % k)
  if (ost + y > n)
    println(-1)
  else
    while (y + ost <= n) {
      print(ost + " ")
      ost += k
    }
}

class MyScanner {
  val in = new BufferedReader(new InputStreamReader(System.in))
  var buffer = in.readLine().split(" ")
  var pos = 0

  def nextInt: Int = {
    if (buffer == null) {
      buffer = in.readLine().split(" ")
      pos = 0
    }
    if (buffer.length <= pos) {
      buffer = in.readLine().split(" ")
      pos = 0
    }
    pos = pos + 1
    buffer(pos - 1).toInt
  }

  def nextString: String = {
    if (buffer == null) {
      buffer = in.readLine().split(" ")
      pos = 0
    }
    if (buffer.length <= pos) {
      buffer = in.readLine().split(" ")
      pos = 0
    }
    pos += 1
    buffer(pos - 1)
  }
}

import java.util.Scanner

object A extends App {
	val in = new Scanner(System.in)
	val y = in.nextInt()
	val k = in.nextInt()
	val n = in.nextInt()
	val m = ((1 + y).toDouble / k.toDouble).ceil.toInt
	if (m * k > n) {
		println(-1)
	} else {
		val sb = new StringBuilder
		for (i <- m * k to n by k) {
			sb.append(i - y)
			sb.append(' ')
		}
		sb.deleteCharAt(sb.length - 1)
		println(sb)
	}
}

object CodeForces {

  def main(args: Array[String]) = {
    val cin = new java.util.Scanner(System.in)
    val y = cin.nextInt()
    val k = cin.nextInt()
    val n = cin.nextInt()
    val res = for ( it <- 1 to n / k; if  it * k -  y > 0 ) yield it * k -  y
    if (res.length == 0) System.out.println(-1)
    else for (it <- res) System.out.print(it + " ")

  }
}

import java.util.Scanner

object A extends App
{
    val cin=new Scanner(System.in);
    while(cin.hasNext())
    {
        val y,k,n=cin.nextInt();
        val ans =for { x_y <- List.range(0,n+1,k) ; if x_y>y } yield(x_y-y);
        if(ans.isEmpty) System.out.println(-1);
        else System.out.println(ans.mkString(" "));
    }
}

object Olymp{
  def main(args: Array[String]): Unit = {
	val Array(y, k, n) = readLine.split(' ').map(Integer.parseInt(_))

	def from(x: Int): Stream[Int] = x #:: from(x + k)

	val ans = from(k - y % k).takeWhile(_ + y <= n)

	if (ans.isEmpty) println(-1)
	else for { i <- ans } print(i + " ")
  }
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(y, k, n) = in.next().split(" ").map(_.toInt)
  val res = (y / k to n / k + 1).map(i => i * k - y)
    .filter(j => j > 0 && j + y <= n)
    .mkString(" ")
  if (res.isEmpty)
    println(-1)
  else
    println(res)
}

import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val y, k, n = sc.nextInt()
  val ans = List.range(k - (y % k), n - y + 1, k)
  println(if (ans.isEmpty) "-1" else ans.mkString(" "))
}

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

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

  val Y, K, N = sc.nextInt

  def solve(): String = {
    val xys = List.range((Y / K + 1) * K, N + 1, K)
    if (xys.size == 0) "-1"
    else xys.map(_ - Y).mkString(" ")
  }

  out.println(solve)
  out.close
}

import java.io.InputStreamReader
import java.io.BufferedReader

object Main extends App {
  val in = new MyScanner()
  var y, k, n = in.nextInt

  var ost = k - (y % k)
  if (ost + y > n)
    println(-1)
  else
    while (y + ost <= n) {
      print(ost + " ")
      ost += k
    }
}

class MyScanner {
  val in = new BufferedReader(new InputStreamReader(System.in))
  var buffer = in.readLine().split(" ")
  var pos = 0

  def nextInt: Int = {
    if (buffer == null) {
      buffer = in.readLine().split(" ")
      pos = 0
    }
    if (buffer.length <= pos) {
      buffer = in.readLine().split(" ")
      pos = 0
    }
    pos = pos + 1
    buffer(pos - 1).toInt
  }

  def nextString: String = {
    if (buffer == null) {
      buffer = in.readLine().split(" ")
      pos = 0
    }
    if (buffer.length <= pos) {
      buffer = in.readLine().split(" ")
      pos = 0
    }
    pos += 1
    buffer(pos - 1)
  }
}

import java.io.InputStreamReader
import java.io.BufferedReader
import java.util.Scanner

object Main extends App {
  val in = new Scanner(new InputStreamReader(System.in))
  var y, k, n = in.nextInt()

  var ost = k - (y % k)
  if (ost + y > n)
    println(-1)
  else
    while (y + ost <= n) {
      print(ost + " ")
      ost += k
    }
}

class MyScanner {
  val in = new BufferedReader(new InputStreamReader(System.in))
  var buffer = in.readLine().split(" ")
  var pos = 0

  def nextInt: Int = {
    if (buffer == null) {
      buffer = in.readLine().split(" ")
      pos = 0
    }
    if (buffer.length <= pos) {
      buffer = in.readLine().split(" ")
      pos = 0
    }
    pos = pos + 1
    buffer(pos - 1).toInt
  }

  def nextString: String = {
    if (buffer == null) {
      buffer = in.readLine().split(" ")
      pos = 0
    }
    if (buffer.length <= pos) {
      buffer = in.readLine().split(" ")
      pos = 0
    }
    pos += 1
    buffer(pos - 1)
  }
}

object Main extends App {
  val in = new MyScanner
  var y, k, n = in.nextInt

  var ost = k - (y % k)
  if (ost + y > n)
    println(-1)
  else
    while (y + ost <= n) {
      print(ost + " ")
      ost += k
    }
}

class MyScanner {
  var buffer = readLine().split(" ")
  var pos = 0

  def nextInt: Int = {
    if (buffer == null) {
      buffer = readLine().split(" ")
      pos = 0
    }
    if (buffer.length <= pos) {
      buffer = readLine().split(" ")
      pos = 0
    }
    pos = pos + 1
    buffer(pos - 1).toInt
  }

  def nextString: String = {
    if (buffer == null) {
      buffer = readLine().split(" ")
      pos = 0
    }
    if (buffer.length <= pos) {
      buffer = readLine().split(" ")
      pos = 0
    }
    pos += 1
    buffer(pos - 1)
  }
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(y, k, n) = in.next().split(" ").map(_.toInt)
  val res = (1 to (n - y) / k + 1).map(i => i * k - y).filter(j => j > 0 && j + y <= n).mkString(" ")
  if (res.isEmpty)
    println(-1)
  else
    println(res)
}

import java.util.Scanner

object A extends App {
	val in = new Scanner(System.in)
	val y = in.nextInt()
	val k = in.nextInt()
	val n = in.nextInt()
	val begin = (y / k + 1) * k
	if (n - begin < 1) {
		println(-1)
	} else {
		val sb = new StringBuilder
		for (i <- begin to n by k) {
			sb.append(i - y)
			sb.append(' ')
		}
		sb.deleteCharAt(sb.size - 1)
		println(sb)
	}
}

object Main {
  def main(args: Array[String]): Unit = {
    val ynk = readLine().split(" ").map(_.toInt)
    val y = ynk(0)
    val n = ynk(2)
    val k = ynk(1)

    val start = ((y + k - 1) / k) * k
    if (start >= n) println("-1")
    else println( (start until n by k).map(_ - y).mkString(" ") )
  }
}

object Main {
  def main(args: Array[String]): Unit = {
    val ynk = readLine().split(" ").map(_.toInt)
    val y = ynk(0)
    val n = ynk(2)
    val k = ynk(1)

    val start = ((y + k - 1) / k) * k
    if (start >= n) println(n)
    else println( (start to n by k).map(_ - y).mkString(" ") )
  }
}

object Main {
  def main(args: Array[String]): Unit = {
    val ynk = readLine().split(" ").map(_.toInt)
    val y = ynk(0)
    val n = ynk(2)
    val k = ynk(1)

    val start =
      if (k == 1) y + 1
      else ((y + k - 1) / k) * k
    if (start > n) println("-1")
    else println( (start to n by k).map(_ - y).mkString(" ") )
  }
}

object Main {
  def main(args: Array[String]): Unit = {
    val ynk = readLine().split(" ").map(_.toInt)
    val y = ynk(0)
    val n = ynk(2)
    val k = ynk(1)

    val start =
      if (k == 1) y + 1
      else ((y + k - 1) / k) * k
    if (start >= n) println("-1")
    else println( (start to n by k).map(_ - y).mkString(" ") )
  }
}


import java.io.FileReader
import java.util
import java.util.Comparator

import collection.Searching._
import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer

object Solution {
  //Console.setIn(new FileReader(new java.io.File("input")))
  //Console.setOut(new PrintStream(new java.io.File("output")))
  var caseNo = 1
  val magicMod = 1000000007

  def doCase() : Unit = {
    val Array(n) = readIntLine()
    val boxes = readIntLine().sorted.reverse

    var piles : ArrayBuffer[List[Int]] = new ArrayBuffer[List[Int]]()

    for (box <- boxes) {
      var placed = false
      for (i <- piles.indices) {
        if (!placed && piles(i).head > box) {
          piles(i) = box :: piles(i)
          placed = true
        }
      }
      if (!placed) {
        piles.append(List(box))
      }
    }
    println(piles.length)
  }

  def main(args: Array[String]): Unit = {
    val noCases = 1
    for (i <- 0 until noCases) {
      doCase()
    }
  }

  def readIntLine(): Array[Int] = {
    readLine().split(" ").map(_.toInt)
  }

  def readLongLine(): Array[Long] = {
    readLine().split(" ").map(_.toLong)
  }

  def readBigIntLine(): Array[BigInt] = {
    readLine().split(" ").map(BigInt.apply)
  }
}

object C extends App {
  val n = scala.io.StdIn.readInt()
  val a = scala.io.StdIn.readLine().split(" ").map(_.toInt)

  val b = a.sorted.foldLeft(List.empty[Int]) ((l, i) => {
    if (l.isEmpty) i :: l
    else if (l.head < i) l.tail :+ i
    else i :: l
  })

  println(b.length)
}

object C extends App {
  val n = scala.io.StdIn.readInt()
  val a = scala.io.StdIn.readLine().split(" ").map(_.toInt)

  val b = a.sorted.foldLeft(List.empty[Int]) ((l, i) => {
    if (l.isEmpty) i :: l
    else if (l.head < i) i :: l.tail
    else i :: l
  })

  println(b.length)
}