object Main {

  def main(args: Array[String]): Unit = {
    val problem = args
    val prob2 = problem.drop(1)

    var maxv = -2000000000
    var minv = problem(0).toInt

    for (i <- prob2) {
      val c = i.toInt
      if (maxv < c - minv) maxv = c - minv
      if (c < minv) minv = c
    }

    print(maxv)

  }
}