object Main extends App {
  import scala.io.StdIn.readLine
  
  	val mushi = readLine
  	val cards = readLine.split(" ").map(_.toInt).toList
  
  	println(cards.sorted.foldLeft(0)((a,b)=> b - a ).toString)   
}