object Main extends App{
    val sc=new java.util.Scanner(System.in)
    val k,n=sc.nextInt
    val a=List.fill(n)(sc.nextInt)
    val p=(0 until n).map(i=>if(i==0)a(n-1)-a(0)else Math.abs(a(i)-a(i-1)))
    val r=p.map(i=>if(n/2<i)i-n/2 else i).toList
    val max=r.max
    val res=n-max
    println(res)
}