import scala.annotation.tailrec
import scala.collection.{immutable, mutable}
import scala.io.StdIn._
object Main extends App {

  val n = readInt()
  //assert(n >= 3)
  val numbers = readLine.trim.split(' ').map(_.toInt).toArray
  //assert(numbers.length >= 3)
  println(calMin(numbers))



  def calMin(numbers: Array[Int]): Int = {
    if (numbers.length < 3) return 0
    var array = numbers.clone()
    var result = Nil: List[Int]
    var temp = minToRight(1, true, array, 0)
    if (isZigZag(array))
      result ::= temp
    array = numbers.clone()
    temp = minToRight(1, false, array, 0)
    if (isZigZag(array))
      result ::= temp
    array = numbers.clone()
    array.swap(1, 2)
    temp = minToRight(1, true, array, 1)
    if (isZigZag(array))
      result ::= temp
    array = numbers.clone()
    array.swap(1, 2)
    temp = minToRight(1, false, array, 1)
    if (isZigZag(array))
      result ::= temp
    result.min
  }
  def isZigZag(numbers: Array[Int]): Boolean = {
    assert(numbers.length >= 3, numbers.mkString(","))
    if (numbers.length < 3) throw new UnknownError()
    val bool = numbers.indices.tail.map{i ⇒ numbers(i - 1) < numbers(i)}
    assert(bool.length >= 2)
    if (bool.length < 2) throw new UnknownError()
    bool.indices.tail.forall{i ⇒ bool(i) != bool(i - 1)}
  }
  @tailrec def minToRight(position: Int,ud: Boolean, numbers: Array[Int], result: Int): Int = {
    if (position >= numbers.length) result
    else {
      if (ud) {
        if (numbers(position - 1) > numbers(position)) minToRight(position + 1, !ud, numbers, result)
        else if (position + 1 < numbers.length) {
          numbers.swap(position, position + 1)
          if (numbers(position - 1) > numbers(position)) minToRight(position + 1, !ud, numbers, result + 1)
          else {
            numbers.swap(position, position + 1)
            numbers.swap(position - 1, position)
            minToRight(position + 1, !ud, numbers, result + 1)
          }
        }else {
          numbers.swap(position - 1, position)
          minToRight(position + 1, !ud, numbers, result + 1)
        }
      }else {
        if (numbers(position - 1) < numbers(position)) minToRight(position + 1, !ud, numbers, result)
        else if (position + 1 < numbers.length) {
          numbers.swap(position, position + 1)
          if (numbers(position - 1) < numbers(position)) minToRight(position + 1, !ud, numbers, result + 1)
          else {
            numbers.swap(position, position + 1)
            numbers.swap(position - 1, position)
            minToRight(position + 1, !ud, numbers, result + 1)
          }
        }else {
          numbers.swap(position - 1, position)
          minToRight(position + 1, !ud, numbers, result + 1)
        }
      }
    }
  }
  implicit class Wrap[T](val array: Array[T]) extends AnyVal {
    def swap(a: Int, b: Int): Unit = {
      val temp = array(a)
      array(a) = array(b)
      array(b) = temp
    }
  }
}
