import scala.util.control.Breaks

object Main extends App{
  def main(N:Int,s:List[Int]) {
    var res=1000000000
    for(i<-0 until N-1) {
      res=List(res,s(i+1)-s(i)).min
    }
    println(res)
  }
  val sc = new java.util.Scanner(System.in)
  val b=new Breaks

  b.breakable {
    while (true) {
      val N = sc.nextInt
      if (N == 0) b.break
      val s = List.fill(N)(sc.nextInt)
      main(N, s)
    }
  }
}