object Main extends App {
  import scala.math._
  
  val n = readLong
  val h = readLine.split(" ").map{_.toLong}.toArray
  
  val dp = Array.fill[Long](n.toInt)(Long.MaxValue)
  dp(0) = 0
  dp(1) = abs(h(1) - h(0))
  
  
  for (i <- 2 until n.toInt) {
    dp(i) = min(dp(i-1)+abs(h(i)-h(i-1)),dp(i-2)+abs(h(i)-h(i-2)))
  }
  
  println(dp(n.toInt-1))
}