import scala.io.StdIn

object Main extends App {
  val inputs = StdIn.readLine().split(" ")
  val N = inputs(0)
  val K = inputs(1)
  val numbers = StdIn.readLine().split(" ").map(_.toInt)

  val min = numbers.zipWithIndex.minBy{case(number, _) => number}

  val restNum = (min._2 - 1, numbers.length - min._1)
  var count = 0
  count = if (restNum._1 % 2 == 0) {
    val left = restNum._1
    val right = restNum._2 - 1
    (left + 1) / 2 + (if (right % 2 == 0) right / 2 else (right + 1) / 2)
  } else {
    restNum._1 / 2 + (if (restNum._2 % 2 == 0) restNum._2 / 2 else (restNum._2 + 1) / 2)
  }

  println(count)
}