read n
read ps
arr=($ps)
ans=0


for ((i=1; i<n-1; i++)); do
    count=0
    if [ ${arr[$((i - 1))]} -lt ${arr[$i]} ]; then
        count=$((count+1))
    fi
    if [ ${arr[$((i + 1))]} -lt ${arr[$i]} ]; then
        count=$((count+1))
    fi
    if [ $count -eq 1 ]; then
        ans=$((ans+1))
    fi
done

echo $ans