input = STDIN.read.split("\n").map{|l| l.split(" ").map{|i| i.to_i}}

N = input[0][0]
H = input[1]

BAG = {}

def jump(i = 0, cost = 0)

  if i == N - 1
    return cost
  end

  if BAG.key?(i)
    return BAG[i] + cost
  end

  c = (H[i] - H[i + 1]).abs
  total = jump(i + 1, cost + c)

  res = 0
  if i < N - 2
    c = (H[i] - H[i + 2]).abs
    total_two = jump(i + 2, cost + c)
    res = [total_two, total].min
  else
    res = total
  end

  c = res - cost
  BAG[i] = c
  return res
end

c = jump()
puts c
