object Main extends App {
  val n = io.StdIn.readInt()
  val h = io.StdIn.readLine().split(' ').map(_.toInt)
  val dp = Array.fill(n)(-1)
  for (i <- 0 until n) {
    if (i == 0) dp(i) = 0
    else {
      val x = {
        val tmp = dp(i-1) + Math.abs(h(i-1) - h(i))
        if (i == 1) tmp else tmp.min(dp(i-2) + Math.abs(h(i-2) - h(i)))
      }
      if (dp(i) == -1 || x < dp(i)) dp(i) = x
    }
  }
  println(dp(n-1))
}